diff --git a/ElectronClient/app.js b/ElectronClient/app.js index e47e62f680..130f5a4961 100644 --- a/ElectronClient/app.js +++ b/ElectronClient/app.js @@ -377,7 +377,7 @@ class Application extends BaseApplication { await this.updateMenu(screen); } - async updateMenu(screen) { + async updateMenu(screen, updateStates = true) { if (this.lastMenuScreen_ === screen) return; const cmdService = CommandService.instance(); @@ -740,7 +740,6 @@ class Application extends BaseApplication { const separator = () => { return { type: 'separator', - screens: ['Main'], }; }; @@ -988,6 +987,8 @@ class Application extends BaseApplication { Menu.setApplicationMenu(menu); this.lastMenuScreen_ = screen; + + if (updateStates) await this.updateMenuItemStates(); } async updateMenuItemStates(state = null) { @@ -1130,7 +1131,7 @@ class Application extends BaseApplication { CommandService.instance().registerDeclaration(declaration); } - this.updateMenu('Main'); + this.updateMenu('Main', false); // Since the settings need to be loaded before the store is created, it will never // receive the SETTING_UPDATE_ALL even, which mean state.settings will not be diff --git a/ElectronClient/commands/startExternalEditing.ts b/ElectronClient/commands/startExternalEditing.ts index 141e72e1ae..c6736b9bc1 100644 --- a/ElectronClient/commands/startExternalEditing.ts +++ b/ElectronClient/commands/startExternalEditing.ts @@ -27,10 +27,14 @@ export const runtime = ():CommandRuntime => { // await comp.saveNoteAndWait(comp.formNote); }, isEnabled: (props:any) => { + if (props.routeName !== 'Main') return false; return !!props.noteId; }, mapStateToProps: (state:any) => { - return { noteId: state.selectedNoteIds.length === 1 ? state.selectedNoteIds[0] : null }; + return { + noteId: state.selectedNoteIds.length === 1 ? state.selectedNoteIds[0] : null, + routeName: state.route.routeName, + }; }, }; }; diff --git a/ElectronClient/commands/stopExternalEditing.ts b/ElectronClient/commands/stopExternalEditing.ts index 5a3f9f68aa..16a76bc64a 100644 --- a/ElectronClient/commands/stopExternalEditing.ts +++ b/ElectronClient/commands/stopExternalEditing.ts @@ -18,10 +18,11 @@ export const runtime = ():CommandRuntime => { ExternalEditWatcher.instance().stopWatching(props.noteId); }, isEnabled: (props:any) => { + if (props.routeName !== 'Main') return false; return !!props.noteId; }, mapStateToProps: (state:any) => { - return { noteId: state.selectedNoteIds.length === 1 ? state.selectedNoteIds[0] : null }; + return { noteId: state.selectedNoteIds.length === 1 ? state.selectedNoteIds[0] : null, routeName: state.route.routeName }; }, }; }; diff --git a/ElectronClient/gui/NoteEditor/utils/useWindowCommandHandler.ts b/ElectronClient/gui/NoteEditor/utils/useWindowCommandHandler.ts index e19418a6fe..4f8b97ab44 100644 --- a/ElectronClient/gui/NoteEditor/utils/useWindowCommandHandler.ts +++ b/ElectronClient/gui/NoteEditor/utils/useWindowCommandHandler.ts @@ -44,6 +44,7 @@ function editorCommandRuntime(declaration:CommandDeclaration, editorRef:any):Com } }, isEnabled: (props:any) => { + if (props.routeName !== 'Main') return false; if (props.markdownEditorViewerOnly) return false; if (!props.noteId) return false; const note = BaseModel.byId(props.notes, props.noteId); @@ -58,6 +59,7 @@ function editorCommandRuntime(declaration:CommandDeclaration, editorRef:any):Com noteVisiblePanes: state.noteVisiblePanes, notes: state.notes, noteId: state.selectedNoteIds.length === 1 ? state.selectedNoteIds[0] : null, + routeName: state.route.routeName, }; }, };