Page MenuHomePhabricator

D7286.id24570.diff
No OneTemporary

D7286.id24570.diff

diff --git a/desktop/src/push-notifications.js b/desktop/src/push-notifications.js
--- a/desktop/src/push-notifications.js
+++ b/desktop/src/push-notifications.js
@@ -18,28 +18,29 @@
return null;
}
+function showNewNotification(payload, handleClick) {
+ if (
+ typeof payload.title !== 'string' ||
+ typeof payload.body !== 'string' ||
+ typeof payload.threadID !== 'string'
+ ) {
+ return;
+ }
+ const { title, body, threadID } = payload;
+ const notif = new Notification({
+ title,
+ body,
+ });
+ notif.on('click', () => handleClick(threadID));
+ notif.show();
+}
+
function listenForNotifications(handleClick: (threadID: string) => void) {
if (process.platform !== 'darwin') {
return;
}
pushNotifications.on('received-apns-notification', (event, userInfo) => {
- if (
- typeof userInfo.title !== 'string' ||
- typeof userInfo.body !== 'string' ||
- typeof userInfo.threadID !== 'string'
- ) {
- return;
- }
- const { title, body, threadID } = userInfo;
-
- const notif = new Notification({
- title,
- body,
- });
- notif.on('click', () => {
- handleClick(threadID);
- });
- notif.show();
+ showNewNotification(userInfo, handleClick);
});
}

File Metadata

Mime Type
text/plain
Expires
Mon, Dec 23, 10:41 AM (18 h, 51 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2694491
Default Alt Text
D7286.id24570.diff (1 KB)

Event Timeline