diff options
author | André Oliveira <37463445+SpecialAro@users.noreply.github.com> | 2024-05-16 19:21:55 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-16 19:21:55 +0100 |
commit | 98814970905d6d976541ea64bb8e052247c9feda (patch) | |
tree | e8a7241d646ba66a040f0112f3aa36dd2d61b924 | |
parent | 6.7.4-nightly.12 [skip ci] (diff) | |
download | ferdium-app-98814970905d6d976541ea64bb8e052247c9feda.tar.gz ferdium-app-98814970905d6d976541ea64bb8e052247c9feda.tar.zst ferdium-app-98814970905d6d976541ea64bb8e052247c9feda.zip |
chore: fix error of .close() (#1766)
-rw-r--r-- | src/webview/notifications.ts | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/src/webview/notifications.ts b/src/webview/notifications.ts index 835869f5c..0da86fbba 100644 --- a/src/webview/notifications.ts +++ b/src/webview/notifications.ts | |||
@@ -34,12 +34,20 @@ export const notificationsClassDefinition = `(() => { | |||
34 | class Notification { | 34 | class Notification { |
35 | static permission = 'granted'; | 35 | static permission = 'granted'; |
36 | 36 | ||
37 | static _notification; | ||
38 | |||
37 | constructor(title = '', options = {}) { | 39 | constructor(title = '', options = {}) { |
38 | window.ferdium.displayNotification(title, options).then(() => { | 40 | Notification._displayNotification(title, options); |
39 | // TODO: After several tries, we couldn't find a way to trigger the native notification onclick event. | 41 | } |
40 | // This was needed so that user could go to the specific context when clicking on the notification (it only goes to the service now). | 42 | |
41 | // For now, we don't do anything here | 43 | static _displayNotification(title, options) { |
42 | }); | 44 | Notification._notification = window.ferdium |
45 | .displayNotification(title, options) | ||
46 | .then(() => { | ||
47 | // TODO: After several tries, we couldn't find a way to trigger the native notification onclick event. | ||
48 | // This was needed so that user could go to the specific context when clicking on the notification (it only goes to the service now). | ||
49 | // For now, we don't do anything here | ||
50 | }); | ||
43 | } | 51 | } |
44 | 52 | ||
45 | static requestPermission(cb) { | 53 | static requestPermission(cb) { |
@@ -53,6 +61,20 @@ class Notification { | |||
53 | onNotify(data) { | 61 | onNotify(data) { |
54 | return data; | 62 | return data; |
55 | } | 63 | } |
64 | |||
65 | close() { | ||
66 | if (Notification._notification) { | ||
67 | Notification._notification = null; | ||
68 | } | ||
69 | } | ||
70 | |||
71 | onclick() {} | ||
72 | |||
73 | onclose() {} | ||
74 | |||
75 | onerror() {} | ||
76 | |||
77 | onshow() {} | ||
56 | } | 78 | } |
57 | 79 | ||
58 | window.Notification = Notification; | 80 | window.Notification = Notification; |