Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3514481
D7286.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D7286.diff
View Options
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,32 @@
return null;
}
+function showNewNotification(
+ payload: { +[string]: mixed },
+ handleClick: (threadID: string) => void,
+) {
+ 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
Details
Attached
Mime Type
text/plain
Expires
Mon, Dec 23, 5:11 AM (18 h, 31 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2693626
Default Alt Text
D7286.diff (1 KB)
Attached To
Mode
D7286: [desktop] Extract showNewNotification function
Attached
Detach File
Event Timeline
Log In to Comment