diff options
| author | David Lönnhager <david.l@mullvad.net> | 2019-10-23 14:33:16 +0200 |
|---|---|---|
| committer | David Lönnhager <david.l@mullvad.net> | 2019-10-23 14:33:16 +0200 |
| commit | fdb1d7d2f90f28005c4f570161f6581db1224f4d (patch) | |
| tree | e4ba3ccc0395725f3d3b0b90ed6c8ee8278f86a8 | |
| parent | ef07d2adf5738a052837781082ea6f845bd7706c (diff) | |
| parent | 0b6e9c61977940ace7328c57993a723390e56acd (diff) | |
| download | mullvadvpn-fdb1d7d2f90f28005c4f570161f6581db1224f4d.tar.xz mullvadvpn-fdb1d7d2f90f28005c4f570161f6581db1224f4d.zip | |
Merge branch 'update-notifications'
| -rw-r--r-- | CHANGELOG.md | 5 | ||||
| -rw-r--r-- | gui/src/main/notification-controller.ts | 44 |
2 files changed, 47 insertions, 2 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index e473fd16a4..27ba3e4c00 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,11 @@ Line wrap the file at 100 chars. Th ## [Unreleased] +### Changed +- Notifications shown when connecting to a server include its location. + +#### Windows +- Use a larger icon in notifications on Windows 10. ## [2019.9] - 2019-10-11 diff --git a/gui/src/main/notification-controller.ts b/gui/src/main/notification-controller.ts index 4b0f59fbf6..515918f50c 100644 --- a/gui/src/main/notification-controller.ts +++ b/gui/src/main/notification-controller.ts @@ -1,4 +1,5 @@ import { app, nativeImage, NativeImage, Notification, shell } from 'electron'; +import os from 'os'; import path from 'path'; import { sprintf } from 'sprintf-js'; import config from '../config.json'; @@ -14,7 +15,16 @@ export default class NotificationController { private notificationIcon?: NativeImage; constructor() { + let usePngIcon; if (process.platform === 'linux') { + usePngIcon = true; + } else if (process.platform === 'win32') { + usePngIcon = parseInt(os.release().split('.')[0], 10) >= 10; + } else { + usePngIcon = false; + } + + if (usePngIcon) { const basePath = path.resolve(path.join(__dirname, '../../assets/images')); this.notificationIcon = nativeImage.createFromPath( path.join(basePath, 'icon-notification.png'), @@ -26,11 +36,41 @@ export default class NotificationController { switch (tunnelState.state) { case 'connecting': if (!this.reconnecting) { - this.showTunnelStateNotification(messages.pgettext('notifications', 'Connecting')); + const details = tunnelState.details; + if (details && details.location && details.location.hostname) { + const msg = sprintf( + // TRANSLATORS: The message showed when a server is being connected to. + // TRANSLATORS: Available placeholder: + // TRANSLATORS: %(location) - name of the server location we're connecting to (e.g. "se-got-003") + messages.pgettext('notifications', 'Connecting to %(location)s'), + { + location: details.location.hostname, + }, + ); + this.showTunnelStateNotification(msg); + } else { + this.showTunnelStateNotification(messages.pgettext('notifications', 'Connecting')); + } } break; case 'connected': - this.showTunnelStateNotification(messages.pgettext('notifications', 'Secured')); + { + const details = tunnelState.details; + if (details.location && details.location.hostname) { + const msg = sprintf( + // TRANSLATORS: The message showed when a server has been connected to. + // TRANSLATORS: Available placeholder: + // TRANSLATORS: %(location) - name of the server location we're connected to (e.g. "se-got-003") + messages.pgettext('notifications', 'Connected to %(location)s'), + { + location: details.location.hostname, + }, + ); + this.showTunnelStateNotification(msg); + } else { + this.showTunnelStateNotification(messages.pgettext('notifications', 'Secured')); + } + } break; case 'disconnected': this.showTunnelStateNotification(messages.pgettext('notifications', 'Unsecured')); |
