From 8af788f034f858e37cff273900766f337d9ecf3d Mon Sep 17 00:00:00 2001 From: Amine Mouafik Date: Sat, 22 Feb 2020 01:59:21 +0100 Subject: Simply update locked state --- src/components/layout/Sidebar.js | 11 +---------- src/lib/Menu.js | 27 +++++++++------------------ 2 files changed, 10 insertions(+), 28 deletions(-) diff --git a/src/components/layout/Sidebar.js b/src/components/layout/Sidebar.js index 48a83c5a1..bd10ccb4a 100644 --- a/src/components/layout/Sidebar.js +++ b/src/components/layout/Sidebar.js @@ -118,21 +118,12 @@ export default @inject('stores', 'actions') @observer class Sidebar extends Comp type="button" className="sidebar__button" onClick={() => { - // Disable lock first - otherwise the application might not update correctly actions.settings.update({ type: 'app', data: { - locked: false, + locked: true, }, }); - setTimeout(() => { - actions.settings.update({ - type: 'app', - data: { - locked: true, - }, - }); - }, 0); }} data-tip={`${intl.formatMessage(messages.lockFerdi)} (${ctrlKey}+Shift+L)`} > diff --git a/src/lib/Menu.js b/src/lib/Menu.js index f2669a106..f66dab111 100644 --- a/src/lib/Menu.js +++ b/src/lib/Menu.js @@ -1,15 +1,15 @@ -import { remote, shell, clipboard } from 'electron'; -import { observable, autorun } from 'mobx'; +import { clipboard, remote, shell } from 'electron'; +import { autorun, observable } from 'mobx'; import { defineMessages } from 'react-intl'; - -import { isMac, ctrlKey, cmdKey } from '../environment'; -import { workspaceStore } from '../features/workspaces/index'; -import { workspaceActions } from '../features/workspaces/actions'; -import { announcementActions } from '../features/announcements/actions'; +import { cmdKey, ctrlKey, isMac } from '../environment'; import { announcementsStore } from '../features/announcements'; +import { announcementActions } from '../features/announcements/actions'; import { todosStore } from '../features/todos'; import { todoActions } from '../features/todos/actions'; import { CUSTOM_WEBSITE_ID } from '../features/webControls/constants'; +import { workspaceActions } from '../features/workspaces/actions'; +import { workspaceStore } from '../features/workspaces/index'; + const { app, Menu, dialog } = remote; @@ -806,21 +806,12 @@ export default class FranzMenu { accelerator: 'CmdOrCtrl+Shift+L', enabled: this.stores.user.isLoggedIn && this.stores.settings.app.lockingFeatureEnabled, click() { - // Disable lock first - otherwise the application might not update correctly actions.settings.update({ type: 'app', data: { - locked: false, + locked: true, }, }); - setTimeout(() => { - actions.settings.update({ - type: 'app', - data: { - locked: true, - }, - }); - }, 0); }, }); @@ -967,7 +958,7 @@ export default class FranzMenu { this.currentTemplate = tpl; const menu = Menu.buildFromTemplate(tpl); - const lockedMenu = Menu.buildFromTemplate([]); + const lockedMenu = new Menu(); Menu.setApplicationMenu(this.stores.user.isLoggedIn && this.stores.settings.app.locked ? lockedMenu : menu); } -- cgit v1.2.3-70-g09d2