mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-09-21 07:46:06 +08:00
feat(quick-replies): Reply from Mac notifications
This commit is contained in:
parent
ded52ce101
commit
977b6a0889
|
@ -50,6 +50,7 @@
|
|||
"moment-timezone": "0.5.4",
|
||||
"mousetrap": "^1.5.3",
|
||||
"nock": "^2",
|
||||
"node-mac-notifier": "0.0.13",
|
||||
"node-uuid": "^1.4",
|
||||
"nslog": "^3",
|
||||
"optimist": "0.4.0",
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
|
||||
class NativeNotifications
|
||||
constructor: ->
|
||||
|
||||
displayNotification: ({title, subtitle, body, tag, canReply, onActivate} = {}) =>
|
||||
n = new Notification(title, {
|
||||
silent: true
|
||||
body: subtitle
|
||||
tag: tag
|
||||
})
|
||||
n.onclick = onActivate
|
||||
n
|
||||
|
||||
module.exports = new NativeNotifications
|
35
src/native-notifications.es6
Normal file
35
src/native-notifications.es6
Normal file
|
@ -0,0 +1,35 @@
|
|||
/* eslint global-require: 0 */
|
||||
let MacNotifierNotification = null;
|
||||
|
||||
class NativeNotifications {
|
||||
displayNotification({title, subtitle, body, tag, canReply, onActivate} = {}) {
|
||||
let notif = null;
|
||||
|
||||
if (process.platform === 'darwin') {
|
||||
MacNotifierNotification = MacNotifierNotification || require('node-mac-notifier');
|
||||
notif = new MacNotifierNotification(title, {
|
||||
bundleId: 'com.nylas.nylas-mail',
|
||||
canReply: canReply,
|
||||
subtitle: subtitle,
|
||||
body: body,
|
||||
id: tag,
|
||||
});
|
||||
notif.addEventListener('reply', ({response}) => {
|
||||
onActivate({response, activationType: 'replied'});
|
||||
});
|
||||
notif.addEventListener('click', () => {
|
||||
onActivate({response: null, activationType: 'clicked'});
|
||||
});
|
||||
} else {
|
||||
notif = new Notification(title, {
|
||||
silent: true,
|
||||
body: subtitle,
|
||||
tag: tag,
|
||||
});
|
||||
notif.onclick = onActivate;
|
||||
}
|
||||
return notif;
|
||||
}
|
||||
}
|
||||
|
||||
export default new NativeNotifications()
|
Loading…
Reference in a new issue