mirror of
https://github.com/SchildiChat/element-web.git
synced 2024-10-01 01:26:12 -04:00
Open thread on native notification click (#20176)
This commit is contained in:
parent
705366ab8c
commit
23b21c940c
@ -368,7 +368,7 @@ export default class ElectronPlatform extends VectorBasePlatform {
|
|||||||
return true;
|
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...
|
// GNOME notification spec parses HTML tags for styling...
|
||||||
// Electron Docs state all supported linux notification systems follow this markup spec
|
// 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
|
// 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, '<').replace(/>/g, '>');
|
msg = msg.replace(/</g, '<').replace(/>/g, '>');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Notifications in Electron use the HTML5 notification API
|
const notification = super.displayNotification(
|
||||||
const notifBody = {
|
title,
|
||||||
body: msg,
|
msg,
|
||||||
silent: true, // we play our own sounds
|
avatarUrl,
|
||||||
};
|
room,
|
||||||
if (avatarUrl) notifBody['icon'] = avatarUrl;
|
ev,
|
||||||
const notification = new window.Notification(title, notifBody);
|
);
|
||||||
|
|
||||||
|
const handler = notification.onclick as Function;
|
||||||
notification.onclick = () => {
|
notification.onclick = () => {
|
||||||
dis.dispatch({
|
handler?.();
|
||||||
action: 'view_room',
|
|
||||||
room_id: room.roomId,
|
|
||||||
});
|
|
||||||
window.focus();
|
|
||||||
this.ipcCall('focusWindow');
|
this.ipcCall('focusWindow');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -20,7 +20,6 @@ import { UpdateCheckStatus } from "matrix-react-sdk/src/BasePlatform";
|
|||||||
import request from 'browser-request';
|
import request from 'browser-request';
|
||||||
import dis from 'matrix-react-sdk/src/dispatcher/dispatcher';
|
import dis from 'matrix-react-sdk/src/dispatcher/dispatcher';
|
||||||
import { _t } from 'matrix-react-sdk/src/languageHandler';
|
import { _t } from 'matrix-react-sdk/src/languageHandler';
|
||||||
import { Room } from "matrix-js-sdk/src/models/room";
|
|
||||||
import { hideToast as hideUpdateToast, showToast as showUpdateToast } from "matrix-react-sdk/src/toasts/UpdateToast";
|
import { hideToast as hideUpdateToast, showToast as showUpdateToast } from "matrix-react-sdk/src/toasts/UpdateToast";
|
||||||
import { Action } from "matrix-react-sdk/src/dispatcher/actions";
|
import { Action } from "matrix-react-sdk/src/dispatcher/actions";
|
||||||
import { CheckUpdatesPayload } from 'matrix-react-sdk/src/dispatcher/payloads/CheckUpdatesPayload';
|
import { CheckUpdatesPayload } from 'matrix-react-sdk/src/dispatcher/payloads/CheckUpdatesPayload';
|
||||||
@ -78,27 +77,6 @@ export default class WebPlatform extends VectorBasePlatform {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
displayNotification(title: string, msg: string, avatarUrl: string, room: Room) {
|
|
||||||
const notifBody = {
|
|
||||||
body: msg,
|
|
||||||
tag: "vector",
|
|
||||||
silent: true, // we play our own sounds
|
|
||||||
};
|
|
||||||
if (avatarUrl) notifBody['icon'] = avatarUrl;
|
|
||||||
const notification = new window.Notification(title, notifBody);
|
|
||||||
|
|
||||||
notification.onclick = function() {
|
|
||||||
dis.dispatch({
|
|
||||||
action: 'view_room',
|
|
||||||
room_id: room.roomId,
|
|
||||||
});
|
|
||||||
window.focus();
|
|
||||||
notification.close();
|
|
||||||
};
|
|
||||||
|
|
||||||
return notification;
|
|
||||||
}
|
|
||||||
|
|
||||||
private getMostRecentVersion(): Promise<string> {
|
private getMostRecentVersion(): Promise<string> {
|
||||||
// We add a cachebuster to the request to make sure that we know about
|
// We add a cachebuster to the request to make sure that we know about
|
||||||
// the most recent version on the origin server. That might not
|
// the most recent version on the origin server. That might not
|
||||||
|
Loading…
Reference in New Issue
Block a user