Shell: do not save the layout before the saved one is restored
A save timer queued before the async startup (settings, profiles, workspaces) finished fired on the still-empty dock and overwrote the stored layout, so a shell reload came back with one fresh Home tab. Saves now wait for layoutReady.
This commit is contained in:
parent
f3baf479b3
commit
0d78a6b5ef
2 changed files with 5 additions and 1 deletions
|
|
@ -832,6 +832,8 @@ export default function Shell() {
|
||||||
}
|
}
|
||||||
// A restored deck tab counts: deck sessions come back to their deck, not a new Home tab.
|
// A restored deck tab counts: deck sessions come back to their deck, not a new Home tab.
|
||||||
if (!api.panels.some(panel => isWeb(panel) || (panel.params as TabParams | undefined)?.kind === 'deck')) addWeb(shell.homeUrl);
|
if (!api.panels.some(panel => isWeb(panel) || (panel.params as TabParams | undefined)?.kind === 'deck')) addWeb(shell.homeUrl);
|
||||||
|
shell.layoutReady = true;
|
||||||
|
saveLayoutSoon();
|
||||||
|
|
||||||
api.onDidLayoutChange(() => { markTitlebarGroups(); scheduleSync(); saveLayoutSoon(); });
|
api.onDidLayoutChange(() => { markTitlebarGroups(); scheduleSync(); saveLayoutSoon(); });
|
||||||
api.onDidAddGroup(() => requestAnimationFrame(markTitlebarGroups));
|
api.onDidAddGroup(() => requestAnimationFrame(markTitlebarGroups));
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,8 @@ export const shell = {
|
||||||
closed: [] as Array<{ url: string; profile?: string; title?: string }>,
|
closed: [] as Array<{ url: string; profile?: string; title?: string }>,
|
||||||
profiles: defaultProfiles() as ProfileSettings,
|
profiles: defaultProfiles() as ProfileSettings,
|
||||||
restoring: false,
|
restoring: false,
|
||||||
|
/** False until the saved layout was read back: an earlier save would overwrite it with an empty dock. */
|
||||||
|
layoutReady: false,
|
||||||
/** Toolbar actions implemented by Shell.tsx (split view, the app's panel). */
|
/** Toolbar actions implemented by Shell.tsx (split view, the app's panel). */
|
||||||
split: (_id: string, _direction: 'right' | 'below') => {},
|
split: (_id: string, _direction: 'right' | 'below') => {},
|
||||||
openPanel: (_from?: string) => {},
|
openPanel: (_from?: string) => {},
|
||||||
|
|
@ -277,7 +279,7 @@ let saveTimer: ReturnType<typeof setTimeout> | undefined;
|
||||||
export function saveLayoutSoon() {
|
export function saveLayoutSoon() {
|
||||||
clearTimeout(saveTimer);
|
clearTimeout(saveTimer);
|
||||||
saveTimer = setTimeout(() => {
|
saveTimer = setTimeout(() => {
|
||||||
if (!shell.api || shell.restoring) return;
|
if (!shell.api || shell.restoring || !shell.layoutReady) return;
|
||||||
try { localStorage.setItem(LAYOUT_KEY, JSON.stringify(shell.api.toJSON())); } catch { /* Session restore is best effort. */ }
|
try { localStorage.setItem(LAYOUT_KEY, JSON.stringify(shell.api.toJSON())); } catch { /* Session restore is best effort. */ }
|
||||||
}, 400);
|
}, 400);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue