From 30afc7bd062398aebe2cf6e0d4b2cd3861f7deac Mon Sep 17 00:00:00 2001 From: Ricardo Cino Date: Sat, 25 Jun 2022 02:18:59 +0200 Subject: chore: improve todo menu behaviour on fresh install (#359) --- src/I18n.tsx | 2 +- src/features/todos/store.js | 4 +++- src/lib/Menu.js | 50 +++++++++++++++++++++++++++------------------ 3 files changed, 34 insertions(+), 22 deletions(-) diff --git a/src/I18n.tsx b/src/I18n.tsx index bf4b08cd1..f5e157d97 100644 --- a/src/I18n.tsx +++ b/src/I18n.tsx @@ -11,7 +11,7 @@ const translations = generatedTranslations(); type Props = { stores: { app: AppStore; - user: typeof UserStore; + user: UserStore; }; children: ReactNode; }; diff --git a/src/features/todos/store.js b/src/features/todos/store.js index e5a26ae04..b5228191c 100644 --- a/src/features/todos/store.js +++ b/src/features/todos/store.js @@ -206,8 +206,10 @@ export default class TodoStore extends FeatureStore { @action _toggleTodosFeatureVisibility = () => { debug('_toggleTodosFeatureVisibility'); + const isFeatureEnabled = !this.settings.isFeatureEnabledByUser; this._updateSettings({ - isFeatureEnabledByUser: !this.settings.isFeatureEnabledByUser, + isFeatureEnabledByUser: isFeatureEnabled, + isTodosPanelVisible: isFeatureEnabled, }); }; diff --git a/src/lib/Menu.js b/src/lib/Menu.js index 54c8c0b77..d3a3163b9 100644 --- a/src/lib/Menu.js +++ b/src/lib/Menu.js @@ -473,15 +473,18 @@ const _titleBarTemplateFactory = (intl, locked) => [ accelerator: `${cmdOrCtrlShortcutKey()}+B`, role: 'toggleNavigationBar', type: 'checkbox', - checked: window['ferdium'].stores.settings.app.navigationBarManualActive, + checked: + window['ferdium'].stores.settings.app.navigationBarManualActive, click: () => { window['ferdium'].actions.settings.update({ type: 'app', data: { - navigationBarManualActive: !window['ferdium'].stores.settings.app.navigationBarManualActive, - } + navigationBarManualActive: + !window['ferdium'].stores.settings.app + .navigationBarManualActive, + }, }); - } + }, }, { label: intl.formatMessage(menuItems.splitModeToggle), @@ -494,9 +497,9 @@ const _titleBarTemplateFactory = (intl, locked) => [ type: 'app', data: { splitMode: !window['ferdium'].stores.settings.app.splitMode, - } + }, }); - } + }, }, { label: intl.formatMessage(menuItems.toggleDarkMode), @@ -631,9 +634,10 @@ class FranzMenu { } const { intl } = window['ferdium']; - const locked = this.stores.settings.app.locked - && this.stores.settings.app.lockingFeatureEnabled - && this.stores.user.isLoggedIn; + const locked = + this.stores.settings.app.locked && + this.stores.settings.app.lockingFeatureEnabled && + this.stores.user.isLoggedIn; const tpl = _titleBarTemplateFactory(intl, locked); const { actions } = this; @@ -664,8 +668,9 @@ class FranzMenu { accelerator: `${cmdOrCtrlShortcutKey()}+${altKey()}+I`, click: () => { const windowWebContents = webContents.fromId(1); - const { isDevToolsOpened, openDevTools, closeDevTools } = windowWebContents; - + const { isDevToolsOpened, openDevTools, closeDevTools } = + windowWebContents; + if (isDevToolsOpened()) { closeDevTools(); } else { @@ -1105,14 +1110,16 @@ class FranzMenu { ? menuItems.closeTodosDrawer : menuItems.openTodosDrawer; - menu.push({ - label: intl.formatMessage(drawerLabel), - accelerator: `${todosToggleShortcutKey()}`, - click: () => { - todoActions.toggleTodosPanel(); - }, - enabled: this.stores.user.isLoggedIn && isFeatureEnabledByUser, - }); + if (isFeatureEnabledByUser) { + menu.push({ + label: intl.formatMessage(drawerLabel), + accelerator: `${todosToggleShortcutKey()}`, + click: () => { + todoActions.toggleTodosPanel(); + }, + enabled: this.stores.user.isLoggedIn && isFeatureEnabledByUser, + }); + } if (!isFeatureEnabledByUser) { menu.push( @@ -1124,6 +1131,7 @@ class FranzMenu { click: () => { todoActions.toggleTodosFeatureVisibility(); }, + enabled: this.stores.user.isLoggedIn, }, ); } @@ -1155,7 +1163,9 @@ class FranzMenu { { label: intl.formatMessage(menuItems.publishDebugInfo), click: () => { - window['ferdium'].features.publishDebugInfo.state.isModalVisible = true; + window[ + 'ferdium' + ].features.publishDebugInfo.state.isModalVisible = true; }, }, ]; -- cgit v1.2.3-54-g00ecf