From ef143a4dbb89cdec0131d876959e3695d32047b0 Mon Sep 17 00:00:00 2001 From: Linus Rath <139418639+rathlinus@users.noreply.github.com> Date: Thu, 24 Sep 2026 20:09:49 +0200 Subject: [PATCH] fix: take a conversation's size from the list row's own account The placeholder cards held for a loading conversation looked its size up by bare thread id whenever the open folder was the message's account. Rows of an "All folders" search or a tag view now come from several accounts and the list keys their conversation sizes by account, so the viewer looks the size up the same way, and only for pages that are the list's own rows. --- src/screens/EmailThreadScreen.tsx | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/screens/EmailThreadScreen.tsx b/src/screens/EmailThreadScreen.tsx index 139f1db6..c9f7b046 100644 --- a/src/screens/EmailThreadScreen.tsx +++ b/src/screens/EmailThreadScreen.tsx @@ -42,6 +42,7 @@ import { pickEmailBody, plainTextBody } from '../lib/email-body'; import { singleLine } from '../lib/single-line'; import { buildForwardAsAttachmentPayload } from '../lib/forward-as-attachment'; import { viewerInstance, viewerPages, type ViewerInstance } from '../lib/viewer-pages'; +import { accountScopedId } from '../lib/thread-utils'; import type { Email, EmailAddress, Identity } from '../api/types'; import type { RootStackParamList } from '../navigation/types'; @@ -218,13 +219,14 @@ function EmailViewer({ route, navigation }: Props) { if (view) return view.ids; return failedThreads.has(threadId) ? [] : null; }, [ownerAccountId, failedThreads]); - // The conversation's size as the open folder's list knows it (only when - // that list is the message's account: thread ids are per account). + // The conversation's size as the store's list knows it, for pages that are + // that list's rows (its counts are keyed by the row's account and thread). + const [storeRows] = React.useState(() => new Set(useEmailStore.getState().emails)); const threadSizeOf = React.useCallback( - (threadId: string): number | undefined => (listAccountId === ownerAccountId - ? useEmailStore.getState().threadCounts[threadId] + (page: Email): number | undefined => (storeRows.has(page) && page.threadId + ? useEmailStore.getState().threadCounts[accountScopedId(page, page.threadId)] : undefined), - [listAccountId, ownerAccountId], + [storeRows], ); const memberOf = React.useCallback( (threadId: string, id: string): Email | undefined => @@ -769,7 +771,7 @@ function EmailViewer({ route, navigation }: Props) { : null } memberOf={memberOf} - threadSizeHint={!disableThreading ? threadSizeOf(item.threadId) : undefined} + threadSizeHint={!disableThreading ? threadSizeOf(item) : undefined} threading={!disableThreading} jmapAccountId={ownerAccountId} currentMailboxRole={currentMailboxRole}