diff --git a/frontend/openchat-client/src/utils/chat.ts b/frontend/openchat-client/src/utils/chat.ts index 5a810541b7..1071e773e0 100644 --- a/frontend/openchat-client/src/utils/chat.ts +++ b/frontend/openchat-client/src/utils/chat.ts @@ -62,6 +62,7 @@ import type { TypersByKey } from "../stores/typing"; import { tallyKey } from "../stores/proposalTallies"; import { hasOwnerRights, isPermitted } from "./permissions"; import { cryptoLookup } from "../stores/crypto"; +import { bigIntMax } from "./bigint"; const MAX_RTC_CONNECTIONS_PER_CHAT = 10; const MERGE_MESSAGES_SENT_BY_SAME_USER_WITHIN_MILLIS = 60 * 1000; // 1 minute @@ -1268,9 +1269,20 @@ function mergeLocalUpdates( ]); message.thread = { - ...current, - ...localUpdates.threadSummary, participantIds, + followedByMe: localUpdates.threadSummary.followedByMe ?? current.followedByMe, + numberOfReplies: Math.max( + localUpdates.threadSummary.numberOfReplies ?? 0, + current.numberOfReplies, + ), + latestEventIndex: Math.max( + localUpdates.threadSummary.latestEventIndex ?? 0, + current.latestEventIndex, + ), + latestEventTimestamp: bigIntMax( + localUpdates.threadSummary.latestEventTimestamp ?? BigInt(0), + current.latestEventTimestamp, + ), }; }