diff options
| author | Andrej Mihajlov <and@codeispoetry.ru> | 2017-03-17 13:00:07 +0000 |
|---|---|---|
| committer | Andrej Mihajlov <and@codeispoetry.ru> | 2017-03-17 13:00:07 +0000 |
| commit | ecdc49cc5866631aef05c5ffab91e46ff907bc36 (patch) | |
| tree | 7e01663f6489fbc2c89315f846012e2d6b97b647 /app/app.js | |
| parent | 3f44c0681bf6786a3fe6b6a0ded129028c8d1f7d (diff) | |
| download | mullvadvpn-ecdc49cc5866631aef05c5ffab91e46ff907bc36.tar.xz mullvadvpn-ecdc49cc5866631aef05c5ffab91e46ff907bc36.zip | |
Update tray assets and hide spinner when window is visible
Diffstat (limited to 'app/app.js')
| -rw-r--r-- | app/app.js | 51 |
1 files changed, 43 insertions, 8 deletions
diff --git a/app/app.js b/app/app.js index 468deca4df..5ac598c1b3 100644 --- a/app/app.js +++ b/app/app.js @@ -44,18 +44,53 @@ if(recentLocation && recentLocation.pathname) { } // Tray icon -const updateTrayIcon = () => { - const getIconType = (s) => { - switch(s) { - case ConnectionState.connected: return TrayIconType.secured; - case ConnectionState.connecting: return TrayIconType.securing; - default: return TrayIconType.unsecured; +let isWindowVisible = false; + +/** + * Get tray icon type based on connection state + * @param {ConnectionState} s - connection state + * @return {Object} + * @property {TrayIconType} type - icon type + * @property {bool} [skipAnimation] - skip animation? + * + */ +const getChangeIconEventData = (s) => { + switch(s) { + case ConnectionState.connected: + return { type: TrayIconType.secured }; + + case ConnectionState.connecting: + // do not display spinner if window is visible + if(isWindowVisible) { + return { type: TrayIconType.unsecured, skipAnimation: true }; + } else { + return { type: TrayIconType.securing }; } - }; + + default: return { type: TrayIconType.unsecured }; + } +}; + +/** + * Update tray icon via IPC call + */ +const updateTrayIcon = () => { const { connect } = store.getState(); - ipcRenderer.send('changeTrayIcon', getIconType(connect.status)); + ipcRenderer.send('changeTrayIcon', getChangeIconEventData(connect.status)); }; +ipcRenderer.on('showWindow', () => { + isWindowVisible = true; + updateTrayIcon(); + console.log('showWindow'); +}); + +ipcRenderer.on('hideWindow', () => { + isWindowVisible = false; + updateTrayIcon(); + console.log('hideWindow'); +}); + // patch backend backend.syncWithReduxStore(store); |
