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.js41
1 files changed, 21 insertions, 20 deletions
diff --git a/src/webview/notifications.js b/src/webview/notifications.js
index 97ce9d69b..4055b10de 100644
--- a/src/webview/notifications.js
+++ b/src/webview/notifications.js
@@ -1,45 +1,46 @@
1const { ipcRenderer } = require('electron'); 1const { ipcRenderer } = require('electron');
2const uuidV1 = require('uuid/v1'); 2const uuidV1 = require('uuid/v1');
3// const FranzNotificationStore = [];
4 3
5class Notification { 4class Notification {
5 static permission = 'granted';
6
6 constructor(title = '', options = {}) { 7 constructor(title = '', options = {}) {
7 this.title = title; 8 this.title = title;
8 this.options = options; 9 this.options = options;
9 this.notificationId = uuidV1(); 10 this.notificationId = uuidV1();
10 this.onclick = () => {};
11 11
12 ipcRenderer.sendToHost('notification', { 12 ipcRenderer.sendToHost('notification', this.onNotify({
13 notificationId: this.notificationId, 13 notificationId: this.notificationId,
14 title, 14 title,
15 options, 15 options,
16 }); 16 }));
17 17
18 ipcRenderer.on(`notification-onclick:${this.notificationId}`, () => { 18 ipcRenderer.once(`notification-onclick:${this.notificationId}`, () => {
19 this.onclick(); 19 this.onclick();
20 }); 20 });
21 } 21 }
22}
23 22
24Notification.permission = 'granted'; 23 static requestPermission(cb = null) {
24 if (!cb) {
25 return new Promise((resolve) => {
26 resolve(Notification.permission);
27 });
28 }
25 29
26Notification.requestPermission = (cb = null) => { 30 if (typeof (cb) === 'function') {
27 console.log(this); 31 return cb(Notification.permission);
28 if (!cb) { 32 }
29 return new Promise((resolve) => { 33
30 resolve(Notification.permission); 34 return Notification.permission;
31 });
32 } 35 }
33 36
34 if (typeof (cb) === 'function') { 37 onNotify(data) {
35 return cb(Notification.permission); 38 return data;
36 } 39 }
37 40
38 return Notification.permission; 41 onClick() {}
39};
40 42
41Notification.close = () => { 43 close() {}
42 // no implementation yet 44}
43};
44 45
45window.Notification = Notification; 46window.Notification = Notification;