fix(chat): do not replay entry animations for already-seen fresh messages (#2124) (#2732)

This commit is contained in:
Serhii Dziupin
2026-08-07 09:16:34 +03:00
committed by GitHub
parent 3fc136c95e
commit 87dbc59bf1
2 changed files with 92 additions and 4 deletions
+7 -4
View File
@@ -44,10 +44,13 @@ export class MessageFreshnessDetector {
const isFresh = message.time.created > (sessionStartTime - 5000);
if (!isFresh) {
this.seenMessageIds.add(message.id);
this.messageCreationTimes.set(message.id, message.time.created);
}
// Record fresh messages too so they animate at most once per detector
// lifetime. The detector is a module singleton that outlives ChatViewport
// remounts; without this, switching away and back re-evaluates the same
// message against the stale session start time (recordSessionStart runs
// in an effect after the first render) and replays the entry animation.
this.seenMessageIds.add(message.id);
this.messageCreationTimes.set(message.id, message.time.created);
return isFresh;
}