diff options
Diffstat (limited to 'gui')
| -rw-r--r-- | gui/packages/desktop/src/renderer/app.js | 25 | ||||
| -rw-r--r-- | gui/packages/desktop/src/renderer/lib/notification-controller.js | 27 |
2 files changed, 27 insertions, 25 deletions
diff --git a/gui/packages/desktop/src/renderer/app.js b/gui/packages/desktop/src/renderer/app.js index 00d3950f3a..5c432c9e75 100644 --- a/gui/packages/desktop/src/renderer/app.js +++ b/gui/packages/desktop/src/renderer/app.js @@ -511,7 +511,7 @@ export default class AppRenderer { this._updateConnectionStatus(tunnelState); this._updateUserLocation(tunnelState.state); this._updateTrayIcon(tunnelState.state); - this._showNotification(tunnelState.state); + this._notificationController.notify(tunnelState); } _setSettings(newSettings: Settings) { @@ -574,29 +574,6 @@ export default class AppRenderer { ipcRenderer.send('change-tray-icon', type); } - - _showNotification(tunnelState: TunnelState) { - switch (tunnelState) { - case 'connecting': - this._notificationController.show('Connecting'); - break; - case 'connected': - this._notificationController.show('Secured'); - break; - case 'disconnected': - this._notificationController.show('Unsecured'); - break; - case 'blocked': - this._notificationController.show('Blocked all connections'); - break; - case 'disconnecting': - // no-op - break; - default: - log.error(`Unexpected TunnelState: ${(tunnelState: empty)}`); - return; - } - } } // An account data cache that helps to throttle RPC requests to get_account_data and retain the diff --git a/gui/packages/desktop/src/renderer/lib/notification-controller.js b/gui/packages/desktop/src/renderer/lib/notification-controller.js index 1d6138d404..c5bf201d90 100644 --- a/gui/packages/desktop/src/renderer/lib/notification-controller.js +++ b/gui/packages/desktop/src/renderer/lib/notification-controller.js @@ -1,11 +1,36 @@ // @flow import { remote } from 'electron'; +import log from 'electron-log'; + +import type { TunnelState } from './daemon-rpc'; export default class NotificationController { _activeNotification: ?Notification; - show(message: string) { + notify(tunnelState: TunnelState) { + switch (tunnelState) { + case 'connecting': + this._show('Connecting'); + break; + case 'connected': + this._show('Secured'); + break; + case 'disconnected': + this._show('Unsecured'); + break; + case 'blocked': + this._show('Blocked all connections'); + break; + case 'disconnecting': + // no-op + break; + default: + log.error(`Unexpected TunnelStateTransition: ${(tunnelState: empty)}`); + } + } + + _show(message: string) { const lastNotification = this._activeNotification; const sameAsLastNotification = lastNotification && lastNotification.body === message; |
