mirror of
https://github.com/duckietm/Nitro-V3.git
synced 2026-06-19 15:06:20 +00:00
Merge pull request #239 from simoleo89/fix/messenger-setread-render
fix(messenger): mark thread read in an effect, not during render
This commit is contained in:
+10
-2
@@ -1,4 +1,4 @@
|
||||
import { FC } from 'react';
|
||||
import { FC, useEffect } from 'react';
|
||||
import { MessengerThread } from '../../../../../api';
|
||||
import { FriendsMessengerThreadGroup } from './FriendsMessengerThreadGroup';
|
||||
|
||||
@@ -6,7 +6,15 @@ export const FriendsMessengerThreadView: FC<{ thread: MessengerThread }> = props
|
||||
{
|
||||
const { thread = null } = props;
|
||||
|
||||
thread.setRead();
|
||||
// Mark the thread read after commit, not during render — render must stay
|
||||
// side-effect free. No dep array: faithfully re-marks on every re-render
|
||||
// (e.g. a new message arriving in the active thread), same as before.
|
||||
useEffect(() =>
|
||||
{
|
||||
if(thread) thread.setRead();
|
||||
});
|
||||
|
||||
if(!thread) return null;
|
||||
|
||||
return (
|
||||
<>
|
||||
|
||||
Reference in New Issue
Block a user