ensure more things trigger rerenders

This commit is contained in:
7w1 committed 2026-07-11 23:25:06 -05:00
1 parent efb7a68dbd
commit 6d1fd022b3
3 files changed
+79 -39

No files matched your search

+44 -38
View File
@@ -258,7 +258,10 @@ const MemoizedTimelineItem = memo(
prev.eventData.willRenderNewDivider === next.eventData.willRenderNewDivider &&
prev.eventData.willRenderDayDivider === next.eventData.willRenderDayDivider &&
prev.eventData.mEvent === next.eventData.mEvent &&
prev.eventData.eventSender === next.eventData.eventSender
prev.eventData.eventSender === next.eventData.eventSender &&
prev.eventData.editId === next.eventData.editId &&
prev.eventData.reactionsKey === next.eventData.reactionsKey &&
prev.eventData.content === next.eventData.content
);
}
);
@@ -325,43 +328,46 @@ export function RoomTimeline({
return myPowerLevel < sendLevel;
}, [powerLevels, mx]);
const settings = useMemo(() => ({
messageLayout,
messageSpacing,
hideReads,
showDeveloperTools,
hour24Clock,
dateFormatString,
mediaAutoLoad,
showBundledPreview,
showUrlPreview,
showClientUrlPreview,
showMaps,
autoplayStickers,
hideMemberInReadOnly,
isReadOnly,
hideMembershipEvents,
hideNickAvatarEvents,
hiddenEvents,
}), [
messageLayout,
messageSpacing,
hideReads,
showDeveloperTools,
hour24Clock,
dateFormatString,
mediaAutoLoad,
showBundledPreview,
showUrlPreview,
showClientUrlPreview,
showMaps,
autoplayStickers,
hideMemberInReadOnly,
isReadOnly,
hideMembershipEvents,
hideNickAvatarEvents,
hiddenEvents,
]);
const settings = useMemo(
() => ({
messageLayout,
messageSpacing,
hideReads,
showDeveloperTools,
hour24Clock,
dateFormatString,
mediaAutoLoad,
showBundledPreview,
showUrlPreview,
showClientUrlPreview,
showMaps,
autoplayStickers,
hideMemberInReadOnly,
isReadOnly,
hideMembershipEvents,
hideNickAvatarEvents,
hiddenEvents,
}),
[
messageLayout,
messageSpacing,
hideReads,
showDeveloperTools,
hour24Clock,
dateFormatString,
mediaAutoLoad,
showBundledPreview,
showUrlPreview,
showClientUrlPreview,
showMaps,
autoplayStickers,
hideMemberInReadOnly,
isReadOnly,
hideMembershipEvents,
hideNickAvatarEvents,
hiddenEvents,
]
);
const nicknames = useAtomValue(nicknamesAtom);
const globalProfiles = useAtomValue(profilesCacheAtom);
+9
View File
@@ -32,6 +32,8 @@ import {
reactionOrEditEvent,
resolveReplyDraftTarget,
unwrapRelationJumpTarget,
getEditedEvent,
getEventReactions,
} from '$utils/room';
import { getMxIdLocalPart, toggleReaction } from '$utils/matrix';
import { useMatrixClient } from '$hooks/useMatrixClient';
@@ -287,6 +289,13 @@ export function ThreadDrawer({ room, threadRootId, onClose, overlay }: ThreadDra
collapsed: false,
willRenderNewDivider: false,
willRenderDayDivider: false,
editId: getEditedEvent(ev.getId() ?? '', ev, timelineSet)?.getId(),
reactionsKey:
getEventReactions(timelineSet, ev.getId() ?? '')
?.getSortedAnnotationsByKey()
?.map((r) => `${r[0]}:${r[1].size}`)
.join(',') ?? '',
content: ev.getContent(),
}));
// forceUpdateCounter makes this recompute whenever events arrive
}, [room, threadRootId, thread, processedEvents, forceUpdateCounter]);
+26 -1
View File
@@ -16,6 +16,8 @@ import {
getRedactionTargetEvent,
collectRelationReactionEvents,
collectRelationEditEvents,
getEditedEvent,
getEventReactions,
} from '$utils/room';
import { inSameDay, minuteDifference } from '$utils/time';
import type { ResolvedHiddenEventSettings } from '$state/hooks/settings';
@@ -48,6 +50,9 @@ export interface ProcessedEvent {
collapsed: boolean;
willRenderNewDivider: boolean;
willRenderDayDivider: boolean;
editId: string | undefined;
reactionsKey: string;
content: unknown;
}
/** Raw timeline indices for skipped events (reactions, edits, …) have no row; walk backward to a visible one. */
@@ -81,7 +86,12 @@ const getPmpId = (ev: MatrixEvent): string | null =>
type ProcessedEventDraft = Omit<
ProcessedEvent,
'collapsed' | 'willRenderNewDivider' | 'willRenderDayDivider'
| 'collapsed'
| 'willRenderNewDivider'
| 'willRenderDayDivider'
| 'editId'
| 'reactionsKey'
| 'content'
>;
const computeCollapseAndDividers = (
@@ -137,11 +147,19 @@ const computeCollapseAndDividers = (
if (willRenderNewDivider) newDivider = false;
if (willRenderDayDivider) dayDivider = false;
const editId = getEditedEvent(draft.id, mEvent, draft.timelineSet)?.getId();
const reactions = getEventReactions(draft.timelineSet, draft.id)?.getSortedAnnotationsByKey();
const reactionsKey = reactions ? reactions.map((r) => `${r[0]}:${r[1].size}`).join(',') : '';
const content = mEvent.getContent();
return {
...draft,
collapsed,
willRenderNewDivider,
willRenderDayDivider,
editId,
reactionsKey,
content,
};
});
};
@@ -492,6 +510,13 @@ export function useProcessedTimeline({
collapsed,
willRenderNewDivider,
willRenderDayDivider,
editId: getEditedEvent(mEventId, mEvent, timelineSet)?.getId(),
reactionsKey:
getEventReactions(timelineSet, mEventId)
?.getSortedAnnotationsByKey()
?.map((r) => `${r[0]}:${r[1].size}`)
.join(',') ?? '',
content: mEvent.getContent(),
};
prevEvent = mEvent;