Folder labels: transient wrong provider suffix while switching accounts in the open drawer #61

Closed
opened 2026-07-01 21:17:27 +00:00 by JMR-dev · 0 comments
JMR-dev commented 2026-07-01 21:17:27 +00:00 (Migrated from github.com)

Origin: code review of PR #54 (drawer folder de-duplication). Transient/cosmetic.

Problem

The de-dup suffix combines drawerAccount with a folders list from a separately-lagging StateFlow (MailboxViewModel: folders = drawerAccount.flatMapLatest { … observeFolders(account.id) … }, so folders' first emission after a switch requires a Room query round-trip), and FolderDrawer never checks folder.accountId against drawerAccount?.id (FolderDrawer.kt:83).

Failure scenario

Gmail account A with colliding Drafts labels shown in the open drawer; user picks Outlook account B in the AccountSwitcher: drawerAccount emits B immediately while folders still holds A's list until B's Room query emits — frames in that gap render A's [Gmail]/Drafts as "Drafts - Outlook". Self-corrects on the next emission. (The pre-#54 label derived from the folder alone and was immune to this desync.)

Suggested fix

Derive the provider label from the folders' own accountId (look the account up from the rendered list's owner) — or skip the provider-suffix branch while folders.firstOrNull()?.accountId != drawerAccount?.id.

Origin: code review of PR #54 (drawer folder de-duplication). Transient/cosmetic. ## Problem The de-dup suffix combines `drawerAccount` with a `folders` list from a separately-lagging StateFlow (`MailboxViewModel`: `folders = drawerAccount.flatMapLatest { … observeFolders(account.id) … }`, so `folders`' first emission after a switch requires a Room query round-trip), and `FolderDrawer` never checks `folder.accountId` against `drawerAccount?.id` (`FolderDrawer.kt:83`). ## Failure scenario Gmail account A with colliding Drafts labels shown in the open drawer; user picks Outlook account B in the AccountSwitcher: `drawerAccount` emits B immediately while `folders` still holds A's list until B's Room query emits — frames in that gap render A's `[Gmail]/Drafts` as **"Drafts - Outlook"**. Self-corrects on the next emission. (The pre-#54 label derived from the folder alone and was immune to this desync.) ## Suggested fix Derive the provider label from the folders' own `accountId` (look the account up from the rendered list's owner) — or skip the provider-suffix branch while `folders.firstOrNull()?.accountId != drawerAccount?.id`.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: JMR-dev/LibreMail#61