From 984d1f69348e99f2feefab9abcf1e24ba944c227 Mon Sep 17 00:00:00 2001 From: Amine Mouafik Date: Wed, 26 Feb 2020 11:49:05 +0100 Subject: Fix lock at startup when previously closed while locked --- src/stores/SettingsStore.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src/stores/SettingsStore.js') diff --git a/src/stores/SettingsStore.js b/src/stores/SettingsStore.js index 59a99a6e0..feee282e4 100644 --- a/src/stores/SettingsStore.js +++ b/src/stores/SettingsStore.js @@ -92,7 +92,18 @@ export default class SettingsStore extends Store { // Lock on startup if enabled in settings if (this.startup && resp.type === 'app' && resp.data.lockingFeatureEnabled) { this.startup = false; - process.nextTick(() => { this.all.app.locked = true }) + process.nextTick(() => { + // If the app was previously closed unlocked + // we can update the `locked` setting and rely on the reaction to lock at startup + if (!this.all.app.locked) { + this.all.app.locked = true; + } else { + // Otherwise the app previously closed in a locked state + // We can't rely on updating the locked setting for the reaction to be triggered + // So we lock manually + window.ferdi.stores.router.push('/auth/locked'); + } + }) } debug('Get appSettings resolves', resp.type, resp.data); Object.assign(this._fileSystemSettingsCache[resp.type], resp.data); -- cgit v1.2.3-70-g09d2