diff options
author | Amine Mouafik <amine@mouafik.fr> | 2020-02-22 02:17:56 +0100 |
---|---|---|
committer | Amine Mouafik <amine@mouafik.fr> | 2020-02-22 02:17:56 +0100 |
commit | 0400dfd1d908d27c6f6e7f96f00c4544628b14f3 (patch) | |
tree | 7159cdd2de41f893245eb49b762b44591d47fe6a /src/stores | |
parent | Simply update locked state (diff) | |
download | ferdium-app-0400dfd1d908d27c6f6e7f96f00c4544628b14f3.tar.gz ferdium-app-0400dfd1d908d27c6f6e7f96f00c4544628b14f3.tar.zst ferdium-app-0400dfd1d908d27c6f6e7f96f00c4544628b14f3.zip |
Add FIXME note about lock at startup
Diffstat (limited to 'src/stores')
-rw-r--r-- | src/stores/SettingsStore.js | 49 |
1 files changed, 18 insertions, 31 deletions
diff --git a/src/stores/SettingsStore.js b/src/stores/SettingsStore.js index da63bc972..bf5a80f90 100644 --- a/src/stores/SettingsStore.js +++ b/src/stores/SettingsStore.js | |||
@@ -1,16 +1,12 @@ | |||
1 | import { ipcRenderer, remote } from 'electron'; | 1 | import { ipcRenderer, remote } from 'electron'; |
2 | import { | 2 | import { action, computed, observable, reaction } from 'mobx'; |
3 | action, computed, observable, reaction, | ||
4 | } from 'mobx'; | ||
5 | import localStorage from 'mobx-localstorage'; | 3 | import localStorage from 'mobx-localstorage'; |
6 | |||
7 | import Store from './lib/Store'; | ||
8 | import Request from './lib/Request'; | ||
9 | import { getLocale } from '../helpers/i18n-helpers'; | ||
10 | import { API } from '../environment'; | ||
11 | |||
12 | import { DEFAULT_APP_SETTINGS, FILE_SYSTEM_SETTINGS_TYPES, LOCAL_SERVER } from '../config'; | 4 | import { DEFAULT_APP_SETTINGS, FILE_SYSTEM_SETTINGS_TYPES, LOCAL_SERVER } from '../config'; |
5 | import { API } from '../environment'; | ||
6 | import { getLocale } from '../helpers/i18n-helpers'; | ||
13 | import { SPELLCHECKER_LOCALES } from '../i18n/languages'; | 7 | import { SPELLCHECKER_LOCALES } from '../i18n/languages'; |
8 | import Request from './lib/Request'; | ||
9 | import Store from './lib/Store'; | ||
14 | 10 | ||
15 | const debug = require('debug')('Ferdi:SettingsStore'); | 11 | const debug = require('debug')('Ferdi:SettingsStore'); |
16 | 12 | ||
@@ -81,6 +77,19 @@ export default class SettingsStore extends Store { | |||
81 | }, | 77 | }, |
82 | ); | 78 | ); |
83 | 79 | ||
80 | const isLoggedIn = Boolean(localStorage.getItem('authToken')); | ||
81 | console.log(this.all.app.lockingFeatureEnabled); | ||
82 | // FIXME: sometime this is true, sometime this is false | ||
83 | // We should lock at startup once we know lockingFeatureEnabled is loaded in the settings | ||
84 | if (isLoggedIn && this.all.app.lockingFeatureEnabled) { | ||
85 | this.actions.settings.update({ | ||
86 | type: 'app', | ||
87 | data: { | ||
88 | locked: true, | ||
89 | }, | ||
90 | }); | ||
91 | } | ||
92 | |||
84 | // Inactivity lock timer | 93 | // Inactivity lock timer |
85 | let inactivityTimer; | 94 | let inactivityTimer; |
86 | remote.getCurrentWindow().on('blur', () => { | 95 | remote.getCurrentWindow().on('blur', () => { |
@@ -100,28 +109,6 @@ export default class SettingsStore extends Store { | |||
100 | clearTimeout(inactivityTimer); | 109 | clearTimeout(inactivityTimer); |
101 | } | 110 | } |
102 | }); | 111 | }); |
103 | |||
104 | // Make sure to lock app on launch if locking feature is enabled | ||
105 | setTimeout(() => { | ||
106 | const isLoggedIn = Boolean(localStorage.getItem('authToken')); | ||
107 | if (isLoggedIn && this.all.app.lockingFeatureEnabled) { | ||
108 | // Disable lock first - otherwise the lock might not get activated corrently | ||
109 | this.actions.settings.update({ | ||
110 | type: 'app', | ||
111 | data: { | ||
112 | locked: false, | ||
113 | }, | ||
114 | }); | ||
115 | setTimeout(() => { | ||
116 | this.actions.settings.update({ | ||
117 | type: 'app', | ||
118 | data: { | ||
119 | locked: true, | ||
120 | }, | ||
121 | }); | ||
122 | }, 0); | ||
123 | } | ||
124 | }, 1000); | ||
125 | } | 112 | } |
126 | 113 | ||
127 | @computed get app() { | 114 | @computed get app() { |