blob: 97ce9d69b7cdf3a26960ff000ccec1798d56ebf4 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
const { ipcRenderer } = require('electron');
const uuidV1 = require('uuid/v1');
// const FranzNotificationStore = [];
class Notification {
constructor(title = '', options = {}) {
this.title = title;
this.options = options;
this.notificationId = uuidV1();
this.onclick = () => {};
ipcRenderer.sendToHost('notification', {
notificationId: this.notificationId,
title,
options,
});
ipcRenderer.on(`notification-onclick:${this.notificationId}`, () => {
this.onclick();
});
}
}
Notification.permission = 'granted';
Notification.requestPermission = (cb = null) => {
console.log(this);
if (!cb) {
return new Promise((resolve) => {
resolve(Notification.permission);
});
}
if (typeof (cb) === 'function') {
return cb(Notification.permission);
}
return Notification.permission;
};
Notification.close = () => {
// no implementation yet
};
window.Notification = Notification;
|