diff options
| author | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2018-12-06 15:11:12 -0200 |
|---|---|---|
| committer | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2018-12-07 07:33:02 -0200 |
| commit | 235a323b730a17ab1adf15fb1935eea45197e05a (patch) | |
| tree | 7eabd4d192f85f96c6f1fa15e4de66c1cd1add30 | |
| parent | 3cba137848ed739a59572b22b029afeb19295ceb (diff) | |
| download | mullvadvpn-235a323b730a17ab1adf15fb1935eea45197e05a.tar.xz mullvadvpn-235a323b730a17ab1adf15fb1935eea45197e05a.zip | |
Handle tray icon when reconnecting
| -rw-r--r-- | gui/packages/desktop/src/main/index.js | 50 |
1 files changed, 41 insertions, 9 deletions
diff --git a/gui/packages/desktop/src/main/index.js b/gui/packages/desktop/src/main/index.js index 5cc11a29b1..92803129bd 100644 --- a/gui/packages/desktop/src/main/index.js +++ b/gui/packages/desktop/src/main/index.js @@ -22,7 +22,6 @@ import type { Location, RelayList, Settings, - TunnelState, TunnelStateTransition, } from './daemon-rpc'; @@ -455,7 +454,7 @@ const ApplicationMain = { _setTunnelState(newState: TunnelStateTransition) { this._tunnelState = newState; - this._updateTrayIcon(newState.state); + this._updateTrayIcon(newState); this._updateLocation(); if (!this._shouldSuppressNotifications()) { @@ -649,13 +648,46 @@ const ApplicationMain = { } }, - _updateTrayIcon(tunnelState: TunnelState) { - const iconTypes: { [TunnelState]: TrayIconType } = { - connected: 'secured', - connecting: 'securing', - blocked: 'securing', - }; - const type = iconTypes[tunnelState] || 'unsecured'; + _trayIconType(tunnelState: TunnelStateTransition): TrayIconType { + switch (tunnelState.state) { + case 'connected': + return 'secured'; + + case 'connecting': + return 'securing'; + + case 'blocked': + return 'securing'; + + case 'disconnecting': + switch (tunnelState.details) { + case 'reconnect': + return 'securing'; + + case 'block': + return 'securing'; + + case 'nothing': + return 'unsecured'; + + default: + log.error(`Invalid after disconnect action: ${(tunnelState.details: empty)}`); + } + break; + + case 'disconnected': + return 'unsecured'; + + default: + log.error(`Invalid tunnel state: ${(tunnelState.state: empty)}`); + } + + // Unreachable, but flow doesn't agree + return 'unsecured'; + }, + + _updateTrayIcon(tunnelState: TunnelStateTransition) { + const type = this._trayIconType(tunnelState); if (this._trayIconController) { this._trayIconController.animateToIcon(type); |
