diff --git a/packages/client-app/src/browser/application.es6 b/packages/client-app/src/browser/application.es6 index e990c8d90..e7f76d318 100644 --- a/packages/client-app/src/browser/application.es6 +++ b/packages/client-app/src/browser/application.es6 @@ -1,6 +1,6 @@ /* eslint global-require: "off" */ -import {BrowserWindow, Menu, app, ipcMain, dialog} from 'electron'; +import {BrowserWindow, Menu, app, ipcMain, dialog, powerMonitor} from 'electron'; import fs from 'fs-plus'; import url from 'url'; @@ -395,6 +395,10 @@ export default class Application extends EventEmitter { }); } + powerMonitor.on('resume', () => { + this.windowManager.sendToAllWindows('app-resumed-from-sleep', {}) + }) + app.on('window-all-closed', () => { this.windowManager.quitWinLinuxIfNoWindows() }); diff --git a/packages/client-sync/src/local-sync-worker/sync-process-manager.js b/packages/client-sync/src/local-sync-worker/sync-process-manager.js index 0aee57efc..6708b852e 100644 --- a/packages/client-sync/src/local-sync-worker/sync-process-manager.js +++ b/packages/client-sync/src/local-sync-worker/sync-process-manager.js @@ -20,13 +20,14 @@ class SyncProcessManager { Actions.wakeLocalSyncWorkerForAccount.listen((accountId) => this.wakeWorkerForAccount(accountId, {interrupt: true}) ); + ipcRenderer.on('app-resumed-from-sleep', () => { + this._wakeAllWorkers({reason: 'Computer resumed from sleep', interrupt: true}) + }) } _onOnlineStatusChanged() { if (OnlineStatusStore.isOnline()) { - Object.keys(this._workersByAccountId).forEach((id) => { - this.wakeWorkerForAccount(id, {reason: 'Came back online'}) - }) + this._wakeAllWorkers({reason: 'Came back online', interrupt: true}) } } @@ -43,6 +44,12 @@ class SyncProcessManager { win.openDevTools() } + _wakeAllWorkers({reason, interrupt} = {}) { + Object.keys(this._workersByAccountId).forEach((id) => { + this.wakeWorkerForAccount(id, {reason, interrupt}) + }) + } + async _resetEmailCache() { if (this._resettingEmailCache) return; this._resettingEmailCache = true