diff options
| author | Andrej Mihajlov <and@mullvad.net> | 2019-06-27 19:43:17 +0200 |
|---|---|---|
| committer | Andrej Mihajlov <and@mullvad.net> | 2019-06-27 20:30:47 +0200 |
| commit | a18523cc1e5a07075403370c93e11564a8d2d94b (patch) | |
| tree | 78f093b22097b53c005eb16bfee5a21db739b60b /gui/src/main | |
| parent | bdf2b46118845c959b06e861a7a3ecec8f54788e (diff) | |
| download | mullvadvpn-a18523cc1e5a07075403370c93e11564a8d2d94b.tar.xz mullvadvpn-a18523cc1e5a07075403370c93e11564a8d2d94b.zip | |
Add notification settings
Diffstat (limited to 'gui/src/main')
| -rw-r--r-- | gui/src/main/gui-settings.ts | 13 | ||||
| -rw-r--r-- | gui/src/main/index.ts | 20 |
2 files changed, 28 insertions, 5 deletions
diff --git a/gui/src/main/gui-settings.ts b/gui/src/main/gui-settings.ts index 57c034b162..7e75d80e13 100644 --- a/gui/src/main/gui-settings.ts +++ b/gui/src/main/gui-settings.ts @@ -10,6 +10,14 @@ export default class GuiSettings { return this.stateValue; } + set enableSystemNotifications(newValue: boolean) { + this.changeStateAndNotify({ ...this.stateValue, enableSystemNotifications: newValue }); + } + + get enableSystemNotifications(): boolean { + return this.stateValue.enableSystemNotifications; + } + set autoConnect(newValue: boolean) { this.changeStateAndNotify({ ...this.stateValue, autoConnect: newValue }); } @@ -38,6 +46,7 @@ export default class GuiSettings { private stateValue: IGuiSettingsState = { autoConnect: true, + enableSystemNotifications: true, monochromaticIcon: false, startMinimized: false, }; @@ -50,6 +59,10 @@ export default class GuiSettings { this.stateValue.autoConnect = typeof settings.autoConnect === 'boolean' ? settings.autoConnect : true; + this.stateValue.enableSystemNotifications = + settings.enableSystemNotifications === 'boolean' + ? settings.enableSystemNotifications + : true; this.stateValue.monochromaticIcon = settings.monochromaticIcon || false; this.stateValue.startMinimized = settings.startMinimized || false; } catch (error) { diff --git a/gui/src/main/index.ts b/gui/src/main/index.ts index b086b97d08..b34cc87fbc 100644 --- a/gui/src/main/index.ts +++ b/gui/src/main/index.ts @@ -407,7 +407,7 @@ class ApplicationMain { // notify user about inconsistent version if ( process.env.NODE_ENV !== 'development' && - !this.shouldSuppressNotifications() && + !this.shouldSuppressNotifications(true) && !this.currentVersion.isConsistent ) { this.notificationController.notifyInconsistentVersion(); @@ -517,7 +517,7 @@ class ApplicationMain { this.updateTrayIcon(newState, this.settings.blockWhenDisconnected); this.updateLocation(); - if (!this.shouldSuppressNotifications()) { + if (!this.shouldSuppressNotifications(false)) { this.notificationController.notifyTunnelState(newState); } @@ -677,7 +677,7 @@ class ApplicationMain { // notify user to update the app if it became unsupported if ( process.env.NODE_ENV !== 'development' && - !this.shouldSuppressNotifications() && + !this.shouldSuppressNotifications(true) && currentVersionInfo.isConsistent && !latestVersionInfo.currentIsSupported && upgradeVersion @@ -713,8 +713,14 @@ class ApplicationMain { } } - private shouldSuppressNotifications(): boolean { - return this.windowController ? this.windowController.isVisible() : false; + private shouldSuppressNotifications(isCriticalNotification: boolean): boolean { + const isVisible = this.windowController ? this.windowController.isVisible() : false; + + if (isCriticalNotification) { + return isVisible; + } else { + return isVisible || !this.guiSettings.enableSystemNotifications; + } } private async updateLocation() { @@ -848,6 +854,10 @@ class ApplicationMain { IpcMainEventChannel.tunnel.handleConnect(() => this.daemonRpc.connectTunnel()); IpcMainEventChannel.tunnel.handleDisconnect(() => this.daemonRpc.disconnectTunnel()); + IpcMainEventChannel.guiSettings.handleEnableSystemNotifications((flag: boolean) => { + this.guiSettings.enableSystemNotifications = flag; + }); + IpcMainEventChannel.guiSettings.handleAutoConnect((autoConnect: boolean) => { this.guiSettings.autoConnect = autoConnect; }); |
