fix: menubar usage

This commit is contained in:
tiddlygit-test 2021-05-15 20:29:13 +08:00
parent f2894047d2
commit d365d964d8
2 changed files with 10 additions and 12 deletions

View file

@ -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}`);

View file

@ -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<BrowserWindowConstructorOptions> = {};
let mainWindowState: windowStateKeeperState | undefined;
const isMainWindow = windowName === WindowNames.main;
if (isMainWindow) {
if (attachToMenubar) {
this.mainWindowMenuBar = await handleAttachToMenuBar();
return;
}
mainWindowState = windowStateKeeper({