1
0
mirror of https://github.com/matrix-org/matrix-react-sdk.git synced 2025-12-22 09:02:11 +03:00

Pass MatrixEvent to displayNotification method (#7355)

This commit is contained in:
Germain
2021-12-15 08:34:52 +00:00
committed by GitHub
parent 42b14bfcd7
commit 53081f52fb
2 changed files with 32 additions and 3 deletions

View File

@@ -170,7 +170,36 @@ export default abstract class BasePlatform {
*/
abstract requestNotificationPermission(): Promise<string>;
abstract displayNotification(title: string, msg: string, avatarUrl: string, room: Room);
public displayNotification(
title: string,
msg: string,
avatarUrl: string,
room: Room,
ev?: MatrixEvent,
): Notification {
const notifBody = {
body: msg,
silent: true, // we play our own sounds
};
if (avatarUrl) notifBody['icon'] = avatarUrl;
const notification = new window.Notification(title, notifBody);
notification.onclick = () => {
const payload: ActionPayload = {
action: Action.ViewRoom,
room_id: room.roomId,
};
if (ev.getThread()) {
payload.event_id = ev.getId();
}
dis.dispatch(payload);
window.focus();
};
return notification;
}
loudNotification(ev: MatrixEvent, room: Room) {
}