Skip to content

Commit 51caaae

Browse files
committed
fix: resolve Copilot review comments on PR SableClient#564
- useTimelineEventRenderer.tsx: Use Math.max(thread.length, replyEvents.length) to avoid undercounting replies when only a subset of events is loaded locally. - ThreadBrowser.tsx: Use Math.max(thread.length, localReplyCount) to show correct total even for threads whose timeline hasn't been fully paginated. - ThreadDrawer.tsx: Align showClientUrlPreview logic with RoomTimeline: require both clientUrlPreview AND encClientUrlPreview in encrypted rooms. - useMessageEdit.ts: Minor wording: 'never stales' → 'never goes stale'.
1 parent 1118a30 commit 51caaae

4 files changed

Lines changed: 4 additions & 4 deletions

File tree

src/app/features/room/ThreadBrowser.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ function ThreadPreview({ room, thread, onClick }: ThreadPreviewProps) {
153153
const localReplyCount = thread.events.filter(
154154
(ev: MatrixEvent) => ev.getId() !== thread.id && !reactionOrEditEvent(ev)
155155
).length;
156-
const replyCount = localReplyCount > 0 ? localReplyCount : thread.length;
156+
const replyCount = Math.max(thread.length ?? 0, localReplyCount);
157157

158158
const lastReply = thread.events
159159
.filter((ev: MatrixEvent) => ev.getId() !== thread.id && !reactionOrEditEvent(ev))

src/app/features/room/ThreadDrawer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ export function ThreadDrawer({ room, threadRootId, onClose, overlay }: ThreadDra
132132
const [hideMemberInReadOnly] = useSetting(settingsAtom, 'hideMembershipInReadOnly');
133133
const showUrlPreview = room.hasEncryptionStateEvent() ? encUrlPreview : urlPreview;
134134
const showClientUrlPreview = room.hasEncryptionStateEvent()
135-
? encClientUrlPreview
135+
? clientUrlPreview && encClientUrlPreview
136136
: clientUrlPreview;
137137

138138
// Memoized parsing options

src/app/hooks/timeline/useTimelineEventRenderer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ function ThreadReplyChip({
148148

149149
if (!thread) return null;
150150

151-
const replyCount = replyEvents.length || (thread.length ?? 0);
151+
const replyCount = Math.max(thread.length ?? 0, replyEvents.length);
152152
if (replyCount === 0) return null;
153153

154154
const uniqueSenders: string[] = [];

src/app/hooks/useMessageEdit.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export function useMessageEdit(
2222
): { editId: string | undefined; handleEdit: (editId?: string) => void } {
2323
const [editId, setEditId] = useState<string | undefined>(undefined);
2424

25-
// Use refs so the callback never stales on options changes.
25+
// Use refs so the callback never goes stale on options changes.
2626
const aliveRef = useRef(options?.alive);
2727
aliveRef.current = options?.alive;
2828
const onResetRef = useRef(options?.onReset);

0 commit comments

Comments
 (0)