mirror of
https://github.com/zadam/trilium.git
synced 2025-12-31 03:34:23 +01:00
fix(window): avoid invalid fallback value for openNoteContexts
Some checks failed
Checks / main (push) Has been cancelled
Some checks failed
Checks / main (push) Has been cancelled
This commit is contained in:
parent
4d2b02eddb
commit
366166a561
@ -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;
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user