diff options
author | Stefan Malzner <stefan@adlk.io> | 2017-10-13 12:29:40 +0200 |
---|---|---|
committer | Stefan Malzner <stefan@adlk.io> | 2017-10-13 12:29:40 +0200 |
commit | 58cda9cc7fb79ca9df6746de7f9662bc08dc156a (patch) | |
tree | 1211600c2a5d3b5f81c435c6896618111a611720 /src/webview/notifications.js | |
download | ferdium-app-58cda9cc7fb79ca9df6746de7f9662bc08dc156a.tar.gz ferdium-app-58cda9cc7fb79ca9df6746de7f9662bc08dc156a.tar.zst ferdium-app-58cda9cc7fb79ca9df6746de7f9662bc08dc156a.zip |
initial commit
Diffstat (limited to 'src/webview/notifications.js')
-rw-r--r-- | src/webview/notifications.js | 45 |
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 @@ | |||
1 | const { ipcRenderer } = require('electron'); | ||
2 | const uuidV1 = require('uuid/v1'); | ||
3 | // const FranzNotificationStore = []; | ||
4 | |||
5 | class 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 | |||
24 | Notification.permission = 'granted'; | ||
25 | |||
26 | Notification.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 | |||
41 | Notification.close = () => { | ||
42 | // no implementation yet | ||
43 | }; | ||
44 | |||
45 | window.Notification = Notification; | ||