From 469bc0ee855f5ca46a781213f0959b7841fadaf3 Mon Sep 17 00:00:00 2001 From: vantezzen Date: Wed, 29 Jan 2020 11:17:04 +0100 Subject: #179 Add inactivity timer --- src/stores/SettingsStore.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/stores/SettingsStore.js') 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 { }, ); + // Inactivity lock timer + let inactivityTimer; + remote.getCurrentWindow().on('blur', () => { + if (this.all.app.inactivityLock !== 0) { + inactivityTimer = setTimeout(() => { + this.actions.settings.update({ + type: 'app', + data: { + locked: true, + }, + }); + }, this.all.app.inactivityLock * 1000 * 60); + } + }); + remote.getCurrentWindow().on('focus', () => { + if (inactivityTimer) { + clearTimeout(inactivityTimer); + } + }); + // Make sure to lock app on launch if locking feature is enabled setTimeout(() => { const isLoggedIn = Boolean(localStorage.getItem('authToken')); -- cgit v1.2.3-70-g09d2