fix(window): avoid invalid fallback value for openNoteContexts
Some checks failed
Checks / main (push) Has been cancelled

This commit is contained in:
SiriusXT 2025-12-30 09:44:58 +08:00
parent 4d2b02eddb
commit 366166a561
3 changed files with 5 additions and 5 deletions

View File

@ -52,7 +52,7 @@ export default class TabManager extends Component {
.filter((t) => !!t);
// Update the current windows 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 windows 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;

View File

@ -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

View File

@ -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) {