summaryrefslogtreecommitdiffhomepage
path: root/gui/src
diff options
context:
space:
mode:
Diffstat (limited to 'gui/src')
-rw-r--r--gui/src/main/notification-controller.ts44
1 files changed, 42 insertions, 2 deletions
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'));