diff --git a/apps/client/src/components/tab_manager.ts b/apps/client/src/components/tab_manager.ts index 682cf29ec..d0fa40730 100644 --- a/apps/client/src/components/tab_manager.ts +++ b/apps/client/src/components/tab_manager.ts @@ -52,7 +52,7 @@ export default class TabManager extends Component { .filter((t) => !!t); // Update the current window’s openNoteContexts in options - const savedWindows = options.getJson("openNoteContexts"); + const savedWindows = options.getJson("openNoteContexts") || []; const win = savedWindows.find(w => w.windowId === appContext.windowId); if (win) { win.contexts = openNoteContexts; @@ -81,7 +81,7 @@ export default class TabManager extends Component { async loadTabs() { // Get the current window’s openNoteContexts - const savedWindows = options.getJson("openNoteContexts"); + const savedWindows = options.getJson("openNoteContexts") || []; const currentWin = savedWindows.find(w => w.windowId === appContext.windowId); const openNoteContexts = currentWin ? currentWin.contexts : undefined; diff --git a/apps/server/src/services/tray.ts b/apps/server/src/services/tray.ts index 739f522f9..72b90cd42 100644 --- a/apps/server/src/services/tray.ts +++ b/apps/server/src/services/tray.ts @@ -197,9 +197,9 @@ function updateTrayMenu() { } function buildClosedWindowsMenu() { - const savedOpenNoteContexts = optionService.getOptionJson("openNoteContexts") || "[]"; + const savedWindows = optionService.getOptionJson("openNoteContexts") || []; const openedWindowIds = windowService.getAllWindowIds(); - const closedWindows = savedOpenNoteContexts + const closedWindows = savedWindows .filter(win => !openedWindowIds.includes(win.windowId)) .sort((a, b) => { // If closedAt is null, it indicates an abnormal closure and should be placed at the end diff --git a/apps/server/src/services/window.ts b/apps/server/src/services/window.ts index 1a1d055f0..4796f1a62 100644 --- a/apps/server/src/services/window.ts +++ b/apps/server/src/services/window.ts @@ -37,7 +37,7 @@ function trackWindowFocus(win: BrowserWindow, windowId: string) { win.on("closed", () => { cls.wrap(() => { - const savedWindows = optionService.getOptionJson("openNoteContexts") || "[]"; + const savedWindows = optionService.getOptionJson("openNoteContexts") || []; const win = savedWindows.find(w => w.windowId === windowId); if (win) {