aboutsummaryrefslogtreecommitdiffstats
path: root/src/stores
diff options
context:
space:
mode:
authorLibravatar Amine Mouafik <amine@mouafik.fr>2020-02-22 02:17:56 +0100
committerLibravatar Amine Mouafik <amine@mouafik.fr>2020-02-22 02:17:56 +0100
commit0400dfd1d908d27c6f6e7f96f00c4544628b14f3 (patch)
tree7159cdd2de41f893245eb49b762b44591d47fe6a /src/stores
parentSimply update locked state (diff)
downloadferdium-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.js49
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 @@
1import { ipcRenderer, remote } from 'electron'; 1import { ipcRenderer, remote } from 'electron';
2import { 2import { action, computed, observable, reaction } from 'mobx';
3 action, computed, observable, reaction,
4} from 'mobx';
5import localStorage from 'mobx-localstorage'; 3import localStorage from 'mobx-localstorage';
6
7import Store from './lib/Store';
8import Request from './lib/Request';
9import { getLocale } from '../helpers/i18n-helpers';
10import { API } from '../environment';
11
12import { DEFAULT_APP_SETTINGS, FILE_SYSTEM_SETTINGS_TYPES, LOCAL_SERVER } from '../config'; 4import { DEFAULT_APP_SETTINGS, FILE_SYSTEM_SETTINGS_TYPES, LOCAL_SERVER } from '../config';
5import { API } from '../environment';
6import { getLocale } from '../helpers/i18n-helpers';
13import { SPELLCHECKER_LOCALES } from '../i18n/languages'; 7import { SPELLCHECKER_LOCALES } from '../i18n/languages';
8import Request from './lib/Request';
9import Store from './lib/Store';
14 10
15const debug = require('debug')('Ferdi:SettingsStore'); 11const 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() {