summaryrefslogtreecommitdiffhomepage
path: root/gui
diff options
context:
space:
mode:
authorJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2018-09-15 10:20:26 -0300
committerJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2018-09-19 09:45:11 -0300
commit5bef2df9f74d82e982db9cfee0657c019666b8ab (patch)
tree1c3e869c0232bb70e942a4028a63b9ab8d9f7111 /gui
parent82a50baf365ff79b876cffcfcbc65712611d7711 (diff)
downloadmullvadvpn-5bef2df9f74d82e982db9cfee0657c019666b8ab.tar.xz
mullvadvpn-5bef2df9f74d82e982db9cfee0657c019666b8ab.zip
Notify tunnel states in notification controller
Diffstat (limited to 'gui')
-rw-r--r--gui/packages/desktop/src/renderer/app.js25
-rw-r--r--gui/packages/desktop/src/renderer/lib/notification-controller.js27
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;