aboutsummaryrefslogtreecommitdiffstats
path: root/src/stores/AppStore.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/stores/AppStore.js')
-rw-r--r--src/stores/AppStore.js29
1 files changed, 26 insertions, 3 deletions
diff --git a/src/stores/AppStore.js b/src/stores/AppStore.js
index 0398b7533..4a00cb294 100644
--- a/src/stores/AppStore.js
+++ b/src/stores/AppStore.js
@@ -27,7 +27,9 @@ import { sleep } from '../helpers/async-helpers';
27 27
28const debug = require('debug')('Franz:AppStore'); 28const debug = require('debug')('Franz:AppStore');
29 29
30const { app, systemPreferences, screen } = remote; 30const {
31 app, systemPreferences, screen, powerMonitor,
32} = remote;
31 33
32const mainWindow = remote.getCurrentWindow(); 34const mainWindow = remote.getCurrentWindow();
33 35
@@ -55,6 +57,8 @@ export default class AppStore extends Store {
55 57
56 @observable isOnline = navigator.onLine; 58 @observable isOnline = navigator.onLine;
57 59
60 @observable timeSuspensionStart;
61
58 @observable timeOfflineStart; 62 @observable timeOfflineStart;
59 63
60 @observable updateStatus = null; 64 @observable updateStatus = null;
@@ -180,6 +184,27 @@ export default class AppStore extends Store {
180 gaPage(pathname); 184 gaPage(pathname);
181 }); 185 });
182 186
187 powerMonitor.on('suspend', () => {
188 debug('System suspended starting timer');
189
190 this.timeSuspensionStart = moment();
191 });
192
193 powerMonitor.on('resume', () => {
194 debug('System resumed, last suspended on', this.timeSuspensionStart.toString());
195
196 if (this.timeSuspensionStart.add(10, 'm').isBefore(moment())) {
197 debug('Reloading services, user info and features');
198
199 this.actions.service.reloadAll();
200
201 this.stores.user.getUserInfoRequest.invalidate({ immediately: true });
202 this.stores.features.featuresRequest.invalidate({ immediately: true });
203
204 statsEvent('resumed-app');
205 }
206 });
207
183 statsEvent('app-start'); 208 statsEvent('app-start');
184 } 209 }
185 210
@@ -279,8 +304,6 @@ export default class AppStore extends Store {
279 if (isValidExternalURL(url)) { 304 if (isValidExternalURL(url)) {
280 shell.openExternal(url); 305 shell.openExternal(url);
281 } 306 }
282
283 gaEvent('External URL', 'open', parsedUrl.host);
284 } 307 }
285 308
286 @action _checkForUpdates() { 309 @action _checkForUpdates() {