diff --git a/sound/new_message.mp3 b/sound/new_message.mp3 new file mode 100644 index 000000000..4918d4584 Binary files /dev/null and b/sound/new_message.mp3 differ diff --git a/ts/test/types/Settings_test.ts b/ts/test/types/Settings_test.ts index 0d233b8cf..609617bc7 100644 --- a/ts/test/types/Settings_test.ts +++ b/ts/test/types/Settings_test.ts @@ -63,7 +63,7 @@ describe('Settings', () => { }); it('should return true', () => { - assert.isFalse(Settings.isAudioNotificationSupported()); + assert.isTrue(Settings.isAudioNotificationSupported()); }); }); }); diff --git a/ts/types/Settings.ts b/ts/types/Settings.ts index 32818754f..57bbdcbcb 100644 --- a/ts/types/Settings.ts +++ b/ts/types/Settings.ts @@ -2,7 +2,8 @@ import * as OS from '../OS'; const MIN_WINDOWS_VERSION = '8.0.0'; -export const isAudioNotificationSupported = () => OS.isWindows(MIN_WINDOWS_VERSION) || OS.isMacOS(); // currently, only linux does not support audio notification natively +export const isAudioNotificationSupported = () => + OS.isWindows(MIN_WINDOWS_VERSION) || OS.isMacOS() || OS.isLinux(); // Using `Notification::tag` has a bug on Windows 7: // https://github.com/electron/electron/issues/11189 diff --git a/ts/util/notifications.ts b/ts/util/notifications.ts index fe30cf862..dfed584d4 100644 --- a/ts/util/notifications.ts +++ b/ts/util/notifications.ts @@ -22,6 +22,8 @@ function filter(text?: string) { .replace(/>/g, '>'); } +let sound: any; + export type SessionNotification = { conversationId: string; iconUrl: string | null; @@ -218,10 +220,16 @@ function update(forceRefresh = false) { } window.drawAttention(); + if (status.shouldPlayNotificationSound) { + if (!sound) { + sound = new Audio('sound/new_message.mp3'); + } + void sound.play(); + } lastNotificationDisplayed = new Notification(title || '', { body: window.platform === 'linux' ? filter(message) : message, icon: iconUrl || undefined, - silent: !status.shouldPlayNotificationSound, + silent: true, }); lastNotificationDisplayed.onclick = () => { window.openFromNotification(lastNotification.conversationId);