nx-webmail: fix hydration race and ensure continued inbox loading
Publish nx-webmail Image (Gitea) / publish (push) Has been cancelled

This commit is contained in:
2026-02-23 15:14:48 +01:00
parent 4277786459
commit 710f5d93c8
4 changed files with 11 additions and 5 deletions
+6
View File
@@ -381,6 +381,10 @@ export default function Webmail() {
&& baseEmailsForSync.length > 0
&& lastLoadedDirection === 'newest';
// Keep refs in sync immediately to avoid stale-closure race conditions
// during progressive hydration and background refresh operations.
activeFolderRef.current = folder;
activeAccountIdRef.current = accountId;
setActiveFolder(folder);
if (!append && !forceRefresh && cachedFolderEmails.length > 0) {
const initial = shouldResetWindow
@@ -606,12 +610,14 @@ export default function Webmail() {
setFolders(normalized);
setIsLoggedIn(true);
setIsAddingAccount(false);
activeAccountIdRef.current = accountId;
setActiveAccountId(accountId);
const defaultFolder = normalized.find((f) => String(f.name).toUpperCase() === String(lastFolder || '').toUpperCase())?.name
|| normalized.find((f) => String(f.name).toUpperCase() === 'INBOX')?.name
|| normalized[0]?.name
|| 'INBOX';
activeFolderRef.current = defaultFolder;
const cachedDefaultFolderEntry = accountCache?.emailsByFolder?.[defaultFolder];
const cachedDefaultEmails = Array.isArray(cachedDefaultFolderEntry)