aboutsummaryrefslogtreecommitdiffstats
path: root/src/webview/notifications.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/webview/notifications.js')
-rw-r--r--src/webview/notifications.js45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/webview/notifications.js b/src/webview/notifications.js
new file mode 100644
index 000000000..97ce9d69b
--- /dev/null
+++ b/src/webview/notifications.js
@@ -0,0 +1,45 @@
1const { ipcRenderer } = require('electron');
2const uuidV1 = require('uuid/v1');
3// const FranzNotificationStore = [];
4
5class Notification {
6 constructor(title = '', options = {}) {
7 this.title = title;
8 this.options = options;
9 this.notificationId = uuidV1();
10 this.onclick = () => {};
11
12 ipcRenderer.sendToHost('notification', {
13 notificationId: this.notificationId,
14 title,
15 options,
16 });
17
18 ipcRenderer.on(`notification-onclick:${this.notificationId}`, () => {
19 this.onclick();
20 });
21 }
22}
23
24Notification.permission = 'granted';
25
26Notification.requestPermission = (cb = null) => {
27 console.log(this);
28 if (!cb) {
29 return new Promise((resolve) => {
30 resolve(Notification.permission);
31 });
32 }
33
34 if (typeof (cb) === 'function') {
35 return cb(Notification.permission);
36 }
37
38 return Notification.permission;
39};
40
41Notification.close = () => {
42 // no implementation yet
43};
44
45window.Notification = Notification;