mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-02-24 08:04:11 +08:00
fix(notifs): Re-display notifs with the same tag on macOS
This commit is contained in:
parent
b16ab73875
commit
fc7016fbaa
1 changed files with 17 additions and 0 deletions
|
@ -9,10 +9,24 @@ if (process.platform === 'darwin') {
|
||||||
}
|
}
|
||||||
|
|
||||||
class NativeNotifications {
|
class NativeNotifications {
|
||||||
|
constructor() {
|
||||||
|
if (MacNotifierNotification) {
|
||||||
|
this._macNotificationsByTag = {};
|
||||||
|
NylasEnv.onBeforeUnload(() => {
|
||||||
|
Object.keys(this._macNotificationsByTag).forEach((key) => {
|
||||||
|
this._macNotificationsByTag[key].close();
|
||||||
|
});
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
displayNotification({title, subtitle, body, tag, canReply, onActivate} = {}) {
|
displayNotification({title, subtitle, body, tag, canReply, onActivate} = {}) {
|
||||||
let notif = null;
|
let notif = null;
|
||||||
|
|
||||||
if (MacNotifierNotification) {
|
if (MacNotifierNotification) {
|
||||||
|
if (tag && this._macNotificationsByTag[tag]) {
|
||||||
|
this._macNotificationsByTag[tag].close();
|
||||||
|
}
|
||||||
notif = new MacNotifierNotification(title, {
|
notif = new MacNotifierNotification(title, {
|
||||||
bundleId: 'com.nylas.nylas-mail',
|
bundleId: 'com.nylas.nylas-mail',
|
||||||
canReply: canReply,
|
canReply: canReply,
|
||||||
|
@ -26,6 +40,9 @@ class NativeNotifications {
|
||||||
notif.addEventListener('click', () => {
|
notif.addEventListener('click', () => {
|
||||||
onActivate({response: null, activationType: 'clicked'});
|
onActivate({response: null, activationType: 'clicked'});
|
||||||
});
|
});
|
||||||
|
if (tag) {
|
||||||
|
this._macNotificationsByTag[tag] = notif;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
notif = new Notification(title, {
|
notif = new Notification(title, {
|
||||||
silent: true,
|
silent: true,
|
||||||
|
|
Loading…
Reference in a new issue