From f2ccf8b21f5d8759c50388507c4d98f895a563dc Mon Sep 17 00:00:00 2001 From: pewdiepie-archdaemon Date: Thu, 11 Jun 2026 17:11:55 +0900 Subject: [PATCH] =?UTF-8?q?Email=20library:=20drop=20the=20'Default'=20chi?= =?UTF-8?q?p=20=E2=80=94=20pick=20an=20explicit=20account=20always?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bug: clicking the dot to change the server-side default account while viewing 'Default' left a desynced state — the email list still showed the OLD default's cached UIDs, but the server's default now pointed at a different account. Opening any email used the visible UID + account_id='' on the read endpoint, which resolved against the NEW default account → wrong email content (or older mail entirely). Fix: remove the 'Default' chip. _loadAccounts now auto-selects the is_default account (or the first one) into state._libAccountId so the list view + every per-email request always carries an explicit account_id and can't desync from set-default. The dot button still lives on each account chip for changing which account the server treats as the default — but it no longer affects which account the list is currently displaying. --- static/js/emailLibrary.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/static/js/emailLibrary.js b/static/js/emailLibrary.js index a42e5c745..6b5b522ff 100644 --- a/static/js/emailLibrary.js +++ b/static/js/emailLibrary.js @@ -1334,6 +1334,15 @@ async function _loadAccounts() { const d = await r.json(); state._libAccounts = d.accounts || []; } catch (_) { state._libAccounts = []; } + // The 'Default' chip is gone — pick an explicit account so the email + // list and any per-email actions (open in new tab, mark read, etc.) + // always carry an account_id and can't desync from the server's + // is_default state. + if (!state._libAccountId && state._libAccounts.length) { + const def = state._libAccounts.find(a => a.is_default) || state._libAccounts[0]; + state._libAccountId = def.id; + _publishActiveAccount(); + } _renderAccountsStrip(); } @@ -1342,10 +1351,11 @@ function _renderAccountsStrip() { if (!strip) return; strip.style.display = 'flex'; const esc = s => String(s || '').replace(/&/g, '&').replace(/Default`; + // The 'Default' chip caused desync bugs (changing the server-side + // default via the dot while still on the cached 'default' view would + // open the wrong account's emails). Each account renders as its own + // chip; the active one is selected explicitly via _loadAccounts. + let html = ''; // 6px dot — matches the sidebar notification-dot size. const _dotFilled = ''; const _dotHollow = '';