Open thread on native notification click (#20176)

This commit is contained in:
Germain 2021-12-15 08:34:54 +00:00 committed by GitHub
parent 705366ab8c
commit 23b21c940c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 35 deletions

View file

@ -368,7 +368,7 @@ export default class ElectronPlatform extends VectorBasePlatform {
return true;
}
displayNotification(title: string, msg: string, avatarUrl: string, room: Room): Notification {
displayNotification(title: string, msg: string, avatarUrl: string, room: Room, ev?: MatrixEvent): Notification {
// GNOME notification spec parses HTML tags for styling...
// Electron Docs state all supported linux notification systems follow this markup spec
// https://github.com/electron/electron/blob/master/docs/tutorial/desktop-environment-integration.md#linux
@ -379,20 +379,17 @@ export default class ElectronPlatform extends VectorBasePlatform {
msg = msg.replace(/</g, '&lt;').replace(/>/g, '&gt;');
}
// Notifications in Electron use the HTML5 notification API
const notifBody = {
body: msg,
silent: true, // we play our own sounds
};
if (avatarUrl) notifBody['icon'] = avatarUrl;
const notification = new window.Notification(title, notifBody);
const notification = super.displayNotification(
title,
msg,
avatarUrl,
room,
ev,
);
const handler = notification.onclick as Function;
notification.onclick = () => {
dis.dispatch({
action: 'view_room',
room_id: room.roomId,
});
window.focus();
handler?.();
this.ipcCall('focusWindow');
};