From d365d964d89d400aef7928321977af0e4adcf652 Mon Sep 17 00:00:00 2001 From: tiddlygit-test Date: Sat, 15 May 2021 20:29:13 +0800 Subject: [PATCH] fix: menubar usage --- src/services/wiki/index.ts | 1 - src/services/windows/index.ts | 21 ++++++++++----------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/services/wiki/index.ts b/src/services/wiki/index.ts index a3c5e770..fec144a1 100644 --- a/src/services/wiki/index.ts +++ b/src/services/wiki/index.ts @@ -355,7 +355,6 @@ export class Wiki implements IWikiService { // if is private repo wiki // if we are creating a sub-wiki just now, restart the main wiki to load content from private wiki if (typeof mainWikiToLink === 'string' && !this.justStartedWiki[mainWikiToLink]) { - // TODO: change getByName to getByMainWikiPath, get by mainWikiPath const mainWorkspace = await this.workspaceService.getByWikiFolderLocation(mainWikiToLink); if (mainWorkspace === undefined) { throw new Error(`mainWorkspace is undefined in wikiStartup() for mainWikiPath ${mainWikiToLink}`); diff --git a/src/services/windows/index.ts b/src/services/windows/index.ts index 0c9d6cf6..ddac80c0 100644 --- a/src/services/windows/index.ts +++ b/src/services/windows/index.ts @@ -106,18 +106,15 @@ export class Window implements IWindowService { const attachToMenubar: boolean = await this.preferenceService.get('attachToMenubar'); const titleBar: boolean = await this.preferenceService.get('titleBar'); + // handle existed window, bring existed window to the front and return. if (existedWindow !== undefined) { - // TODO: handle this menubar logic - if (attachToMenubar) { - if (this.mainWindowMenuBar !== undefined) { - this.mainWindowMenuBar.on('ready', () => { - if (this.mainWindowMenuBar !== undefined) { - void this.mainWindowMenuBar.showWindow(); - } - }); - } else { - // create window with menubar - } + if (attachToMenubar && this.mainWindowMenuBar !== undefined) { + this.mainWindowMenuBar.on('ready', () => { + if (this.mainWindowMenuBar !== undefined) { + void this.mainWindowMenuBar.showWindow(); + } + }); + return; } if (recreate === true || (typeof recreate === 'function' && existedWindowMeta !== undefined && recreate(existedWindowMeta))) { existedWindow.close(); @@ -126,12 +123,14 @@ export class Window implements IWindowService { } } + // create new window let mainWindowConfig: Partial = {}; let mainWindowState: windowStateKeeperState | undefined; const isMainWindow = windowName === WindowNames.main; if (isMainWindow) { if (attachToMenubar) { this.mainWindowMenuBar = await handleAttachToMenuBar(); + return; } mainWindowState = windowStateKeeper({