diff options
Diffstat (limited to 'src/stores/SettingsStore.js')
-rw-r--r-- | src/stores/SettingsStore.js | 38 |
1 files changed, 15 insertions, 23 deletions
diff --git a/src/stores/SettingsStore.js b/src/stores/SettingsStore.js index bf5a80f90..59a99a6e0 100644 --- a/src/stores/SettingsStore.js +++ b/src/stores/SettingsStore.js | |||
@@ -12,6 +12,7 @@ const debug = require('debug')('Ferdi:SettingsStore'); | |||
12 | 12 | ||
13 | export default class SettingsStore extends Store { | 13 | export default class SettingsStore extends Store { |
14 | @observable updateAppSettingsRequest = new Request(this.api.local, 'updateAppSettings'); | 14 | @observable updateAppSettingsRequest = new Request(this.api.local, 'updateAppSettings'); |
15 | startup = true; | ||
15 | 16 | ||
16 | fileSystemSettingsTypes = FILE_SYSTEM_SETTINGS_TYPES; | 17 | fileSystemSettingsTypes = FILE_SYSTEM_SETTINGS_TYPES; |
17 | 18 | ||
@@ -26,16 +27,6 @@ export default class SettingsStore extends Store { | |||
26 | // Register action handlers | 27 | // Register action handlers |
27 | this.actions.settings.update.listen(this._update.bind(this)); | 28 | this.actions.settings.update.listen(this._update.bind(this)); |
28 | this.actions.settings.remove.listen(this._remove.bind(this)); | 29 | this.actions.settings.remove.listen(this._remove.bind(this)); |
29 | |||
30 | ipcRenderer.on('appSettings', (event, resp) => { | ||
31 | debug('Get appSettings resolves', resp.type, resp.data); | ||
32 | |||
33 | Object.assign(this._fileSystemSettingsCache[resp.type], resp.data); | ||
34 | }); | ||
35 | |||
36 | this.fileSystemSettingsTypes.forEach((type) => { | ||
37 | ipcRenderer.send('getAppSettings', type); | ||
38 | }); | ||
39 | } | 30 | } |
40 | 31 | ||
41 | async setup() { | 32 | async setup() { |
@@ -77,19 +68,6 @@ export default class SettingsStore extends Store { | |||
77 | }, | 68 | }, |
78 | ); | 69 | ); |
79 | 70 | ||
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 | |||
93 | // Inactivity lock timer | 71 | // Inactivity lock timer |
94 | let inactivityTimer; | 72 | let inactivityTimer; |
95 | remote.getCurrentWindow().on('blur', () => { | 73 | remote.getCurrentWindow().on('blur', () => { |
@@ -109,6 +87,20 @@ export default class SettingsStore extends Store { | |||
109 | clearTimeout(inactivityTimer); | 87 | clearTimeout(inactivityTimer); |
110 | } | 88 | } |
111 | }); | 89 | }); |
90 | |||
91 | ipcRenderer.on('appSettings', (event, resp) => { | ||
92 | // Lock on startup if enabled in settings | ||
93 | if (this.startup && resp.type === 'app' && resp.data.lockingFeatureEnabled) { | ||
94 | this.startup = false; | ||
95 | process.nextTick(() => { this.all.app.locked = true }) | ||
96 | } | ||
97 | debug('Get appSettings resolves', resp.type, resp.data); | ||
98 | Object.assign(this._fileSystemSettingsCache[resp.type], resp.data); | ||
99 | }); | ||
100 | |||
101 | this.fileSystemSettingsTypes.forEach((type) => { | ||
102 | ipcRenderer.send('getAppSettings', type); | ||
103 | }); | ||
112 | } | 104 | } |
113 | 105 | ||
114 | @computed get app() { | 106 | @computed get app() { |