MM-36234: CRT, handle click on notification (#1699)

Clicking on a notification that regards a reply to a thread,
and when the user has CRT set to ON, should open the corresponding thread.

This is done by passing the URL to push to the browser along side the
notification.

Webapp: If a `url` is passed it will be used, otherwise the URL pushed to
history would be the corresponding channel (as is right now).
This commit is contained in:
Kyriakos Z
2021-08-19 17:36:07 +03:00
committed by GitHub
parent 40dfbdb884
commit 9ce5cb759d
3 changed files with 8 additions and 7 deletions

View File

@@ -747,8 +747,8 @@ function initializeAfterAppReady() {
// ipc communication event handlers
//
function handleMentionNotification(event: IpcMainEvent, title: string, body: string, channel: {id: string}, teamId: string, silent: boolean, data: MentionData) {
displayMention(title, body, channel, teamId, silent, event.sender, data);
function handleMentionNotification(event: IpcMainEvent, title: string, body: string, channel: {id: string}, teamId: string, url: string, silent: boolean, data: MentionData) {
displayMention(title, body, channel, teamId, url, silent, event.sender, data);
}
function handleOpenAppMenu() {

View File

@@ -16,7 +16,7 @@ import {DownloadNotification} from './Download';
const currentNotifications = new Map();
export function displayMention(title: string, body: string, channel: {id: string}, teamId: string, silent: boolean, webcontents: Electron.WebContents, data: MentionData) {
export function displayMention(title: string, body: string, channel: {id: string}, teamId: string, url: string, silent: boolean, webcontents: Electron.WebContents, data: MentionData) {
if (!Notification.isSupported()) {
log.error('notification not supported');
return;
@@ -53,7 +53,7 @@ export function displayMention(title: string, body: string, channel: {id: string
mention.on('click', () => {
if (serverName) {
windowManager.switchServer(serverName);
webcontents.send('notification-clicked', {channel, teamId});
webcontents.send('notification-clicked', {channel, teamId, url});
}
});
mention.show();

View File

@@ -110,8 +110,8 @@ window.addEventListener('message', ({origin, data = {}} = {}) => {
// it will be captured by itself too
break;
case 'dispatch-notification': {
const {title, body, channel, teamId, silent, data: messageData} = message;
ipcRenderer.send(NOTIFY_MENTION, title, body, channel, teamId, silent, messageData);
const {title, body, channel, teamId, url, silent, data: messageData} = message;
ipcRenderer.send(NOTIFY_MENTION, title, body, channel, teamId, url, silent, messageData);
break;
}
default:
@@ -124,13 +124,14 @@ window.addEventListener('message', ({origin, data = {}} = {}) => {
}
});
const handleNotificationClick = ({channel, teamId}) => {
const handleNotificationClick = ({channel, teamId, url}) => {
window.postMessage(
{
type: 'notification-clicked',
message: {
channel,
teamId,
url,
},
},
window.location.origin,