From 44f12f266e9312c80be63b6d12c65552a40a3877 Mon Sep 17 00:00:00 2001 From: pewdiepie-archdaemon Date: Thu, 11 Jun 2026 17:15:49 +0900 Subject: [PATCH] Email library: await _loadAccounts before loading emails MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit After dropping the 'Default' chip, _loadAccounts started setting state._libAccountId asynchronously while _loadEmails fired in parallel with the still-null id. The list request was going out with no account_id (so the server defaulted) while subsequent per-email reads used the explicit id set after _loadAccounts resolved — back to the same desync the chip-removal was meant to fix. Sequence them: await _loadAccounts first, then kick off the folders / reminders / emails fetches. The list always carries the right account_id from the very first call. --- static/js/emailLibrary.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/static/js/emailLibrary.js b/static/js/emailLibrary.js index 9a6758d6b..77c144026 100644 --- a/static/js/emailLibrary.js +++ b/static/js/emailLibrary.js @@ -1321,10 +1321,15 @@ export function openEmailLibrary(opts = {}) { document.addEventListener('keydown', state._libEscHandler, true); _renderAccountsLoading(); - _loadAccounts(); - _loadFolders(); - _loadEmailReminderBellVisibility(); - _loadEmails(); + // Await accounts before loading emails so the list request carries the + // right account_id from the very first fetch (now that we auto-select + // an explicit account instead of relying on a 'Default' chip). + (async () => { + await _loadAccounts(); + _loadFolders(); + _loadEmailReminderBellVisibility(); + _loadEmails(); + })(); } async function _loadAccounts() {