nx-webmail: fix hydration race and ensure continued inbox loading
Publish nx-webmail Image (Gitea) / publish (push) Has been cancelled
Publish nx-webmail Image (Gitea) / publish (push) Has been cancelled
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user