mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-12-27 02:23:28 +08:00
Primitive notification implementation on mac
This commit is contained in:
parent
45f3ebfabd
commit
6ba3cd966d
1 changed files with 7 additions and 53 deletions
|
@ -12,19 +12,6 @@ const DEFAULT_ICON = path.resolve(
|
|||
'mailspring.png'
|
||||
);
|
||||
|
||||
// TODO: Fix notifications on MacOS
|
||||
let MacNotifierNotification = null;
|
||||
if (platform === 'darwin') {
|
||||
try {
|
||||
MacNotifierNotification = true
|
||||
// MacNotifierNotification = require('node-mac-notifier');
|
||||
} catch (err) {
|
||||
console.error(
|
||||
'node-mac-notifier (a platform-specific optionalDependency) was not installed correctly! Check the Travis build log for errors.'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
type INotificationCallback = (
|
||||
args: { response: string | null; activationType: 'replied' | 'clicked' }
|
||||
) => any;
|
||||
|
@ -43,14 +30,6 @@ class NativeNotifications {
|
|||
private resolvedIcon: string = null;
|
||||
|
||||
constructor() {
|
||||
/*if (MacNotifierNotification) {
|
||||
AppEnv.onBeforeUnload(() => {
|
||||
Object.keys(this._macNotificationsByTag).forEach(key => {
|
||||
this._macNotificationsByTag[key].close();
|
||||
});
|
||||
return true;
|
||||
});
|
||||
}*/
|
||||
this.resolvedIcon = this.getIcon();
|
||||
}
|
||||
|
||||
|
@ -142,38 +121,13 @@ class NativeNotifications {
|
|||
return null;
|
||||
}
|
||||
|
||||
if (MacNotifierNotification) {
|
||||
//if (false) {
|
||||
if (tag && this._macNotificationsByTag[tag]) {
|
||||
this._macNotificationsByTag[tag].close();
|
||||
}
|
||||
notif = new Notification(title, {
|
||||
//bundleId: 'com.mailspring.mailspring',
|
||||
hasReply: canReply,
|
||||
replyPlaceholder: "placholder",
|
||||
subtitle: subtitle,
|
||||
body: body,
|
||||
id: tag,
|
||||
icon: this.resolvedIcon,
|
||||
});
|
||||
notif.addEventListener('reply', ({ response }) => {
|
||||
onActivate({ response, activationType: 'replied' });
|
||||
});
|
||||
notif.addEventListener('click', () => {
|
||||
onActivate({ response: null, activationType: 'clicked' });
|
||||
});
|
||||
if (tag) {
|
||||
this._macNotificationsByTag[tag] = notif;
|
||||
}
|
||||
} else {
|
||||
notif = new Notification(title, {
|
||||
silent: true,
|
||||
body: subtitle,
|
||||
tag: tag,
|
||||
icon: this.resolvedIcon,
|
||||
});
|
||||
notif.onclick = onActivate;
|
||||
}
|
||||
notif = new Notification(title, {
|
||||
silent: true,
|
||||
body: subtitle,
|
||||
tag: tag,
|
||||
icon: this.resolvedIcon,
|
||||
});
|
||||
notif.onclick = onActivate;
|
||||
return notif;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue