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:
DuckieTM
2026-06-15 07:14:47 +02:00
committed by GitHub
@@ -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 (
<>