From 9fede7e4674bb0b5363567366a33408095569c86 Mon Sep 17 00:00:00 2001
From: Fedor Indutny <79877362+indutny-signal@users.noreply.github.com>
Date: Wed, 26 Feb 2025 12:42:31 -0800
Subject: [PATCH] Use ms-winsoundevent:Notification.IM on Windows
---
app/renderWindowsToast.tsx | 5 ++
ts/test-node/app/renderWindowsToast_test.tsx | 76 ++++++++++++++++----
2 files changed, 69 insertions(+), 12 deletions(-)
diff --git a/app/renderWindowsToast.tsx b/app/renderWindowsToast.tsx
index 3d3e0ccb6c..dbf9d35fa1 100644
--- a/app/renderWindowsToast.tsx
+++ b/app/renderWindowsToast.tsx
@@ -33,6 +33,7 @@ const Text = (props: { id: string; children: React.ReactNode }) =>
React.createElement('text', props);
const Image = (props: { id: string; src: string; 'hint-crop': string }) =>
React.createElement('image', props);
+const Audio = (props: { src: string }) => React.createElement('audio', props);
export function renderWindowsToast({
avatarPath,
@@ -51,6 +52,8 @@ export function renderWindowsToast({
const template = avatarPath ? 'ToastImageAndText02' : 'ToastText02';
let launch: URL;
+ let audio: React.ReactNode | undefined;
+
// Note:
// 1) this maps to the notify() function in services/notifications.ts
// 2) this also maps to the url-handling in main.ts
@@ -58,6 +61,7 @@ export function renderWindowsToast({
launch = showConversationRoute.toAppUrl({
token,
});
+ audio = ;
} else if (type === NotificationType.IncomingGroupCall) {
launch = startCallLobbyRoute.toAppUrl({
token,
@@ -79,6 +83,7 @@ export function renderWindowsToast({
{body}
+ {audio}
);
}
diff --git a/ts/test-node/app/renderWindowsToast_test.tsx b/ts/test-node/app/renderWindowsToast_test.tsx
index 2abea2c591..b11e3e6859 100644
--- a/ts/test-node/app/renderWindowsToast_test.tsx
+++ b/ts/test-node/app/renderWindowsToast_test.tsx
@@ -16,8 +16,18 @@ describe('renderWindowsToast', () => {
type: NotificationType.Message,
});
- const expected =
- 'AliceHi there!';
+ const expected = [
+ '',
+ '',
+ '',
+ '',
+ 'Alice',
+ 'Hi there!',
+ '',
+ '',
+ '',
+ '',
+ ].join('');
assert.strictEqual(xml, expected);
});
@@ -30,8 +40,17 @@ describe('renderWindowsToast', () => {
type: NotificationType.Message,
});
- const expected =
- 'AliceHi there!';
+ const expected = [
+ '',
+ '',
+ '',
+ 'Alice',
+ 'Hi there!',
+ '',
+ '',
+ '',
+ '',
+ ].join('');
assert.strictEqual(xml, expected);
});
@@ -44,8 +63,17 @@ describe('renderWindowsToast', () => {
type: NotificationType.Message,
});
- const expected =
- 'AliceHi there!';
+ const expected = [
+ '',
+ '',
+ '',
+ 'Alice',
+ 'Hi there!',
+ '',
+ '',
+ '',
+ '',
+ ].join('');
assert.strictEqual(xml, expected);
});
@@ -58,8 +86,16 @@ describe('renderWindowsToast', () => {
type: NotificationType.IncomingCall,
});
- const expected =
- 'AliceHi there!';
+ const expected = [
+ '',
+ '',
+ '',
+ 'Alice',
+ 'Hi there!',
+ '',
+ '',
+ '',
+ ].join('');
assert.strictEqual(xml, expected);
});
@@ -72,8 +108,16 @@ describe('renderWindowsToast', () => {
type: NotificationType.IncomingGroupCall,
});
- const expected =
- 'AliceHi there!';
+ const expected = [
+ '',
+ '',
+ '',
+ 'Alice',
+ 'Hi there!',
+ '',
+ '',
+ '',
+ ].join('');
assert.strictEqual(xml, expected);
});
@@ -86,8 +130,16 @@ describe('renderWindowsToast', () => {
type: NotificationType.IsPresenting,
});
- const expected =
- 'AliceHi there!';
+ const expected = [
+ '',
+ '',
+ '',
+ 'Alice',
+ 'Hi there!',
+ '',
+ '',
+ '',
+ ].join('');
assert.strictEqual(xml, expected);
});