diff options
author | vantezzen <hello@vantezzen.io> | 2020-01-29 11:17:04 +0100 |
---|---|---|
committer | vantezzen <hello@vantezzen.io> | 2020-01-29 11:17:04 +0100 |
commit | 469bc0ee855f5ca46a781213f0959b7841fadaf3 (patch) | |
tree | 428cfd5359d992bc0a8b9855d3d8a57301068a6a /src/stores | |
parent | Bump version number (diff) | |
download | ferdium-app-469bc0ee855f5ca46a781213f0959b7841fadaf3.tar.gz ferdium-app-469bc0ee855f5ca46a781213f0959b7841fadaf3.tar.zst ferdium-app-469bc0ee855f5ca46a781213f0959b7841fadaf3.zip |
#179 Add inactivity timer
Diffstat (limited to 'src/stores')
-rw-r--r-- | src/stores/SettingsStore.js | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/stores/SettingsStore.js b/src/stores/SettingsStore.js index 051e86be2..8a5ee7204 100644 --- a/src/stores/SettingsStore.js +++ b/src/stores/SettingsStore.js | |||
@@ -79,6 +79,26 @@ export default class SettingsStore extends Store { | |||
79 | }, | 79 | }, |
80 | ); | 80 | ); |
81 | 81 | ||
82 | // Inactivity lock timer | ||
83 | let inactivityTimer; | ||
84 | remote.getCurrentWindow().on('blur', () => { | ||
85 | if (this.all.app.inactivityLock !== 0) { | ||
86 | inactivityTimer = setTimeout(() => { | ||
87 | this.actions.settings.update({ | ||
88 | type: 'app', | ||
89 | data: { | ||
90 | locked: true, | ||
91 | }, | ||
92 | }); | ||
93 | }, this.all.app.inactivityLock * 1000 * 60); | ||
94 | } | ||
95 | }); | ||
96 | remote.getCurrentWindow().on('focus', () => { | ||
97 | if (inactivityTimer) { | ||
98 | clearTimeout(inactivityTimer); | ||
99 | } | ||
100 | }); | ||
101 | |||
82 | // Make sure to lock app on launch if locking feature is enabled | 102 | // Make sure to lock app on launch if locking feature is enabled |
83 | setTimeout(() => { | 103 | setTimeout(() => { |
84 | const isLoggedIn = Boolean(localStorage.getItem('authToken')); | 104 | const isLoggedIn = Boolean(localStorage.getItem('authToken')); |