aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Stefan Malzner <stefan@adlk.io>2017-10-30 10:47:57 +0100
committerLibravatar GitHub <noreply@github.com>2017-10-30 10:47:57 +0100
commit2e07a02aae30f8d9dc8532c7eed3415d76d3b2c4 (patch)
tree90f929642daa7969a0bdac7f41172fbb086a3f4f
parentMerge pull request #155 from dannyqiu/fix-theme-change (diff)
parentMerge branch 'develop' into notificationTitleFix (diff)
downloadferdium-app-2e07a02aae30f8d9dc8532c7eed3415d76d3b2c4.tar.gz
ferdium-app-2e07a02aae30f8d9dc8532c7eed3415d76d3b2c4.tar.zst
ferdium-app-2e07a02aae30f8d9dc8532c7eed3415d76d3b2c4.zip
Merge pull request #160 from GustavoKatel/notificationTitleFix
Add onNotify event to let recipes update/change notifications before send them.
-rw-r--r--src/stores/ServicesStore.js5
-rw-r--r--src/webview/lib/RecipeWebview.js6
-rw-r--r--src/webview/notifications.js8
3 files changed, 15 insertions, 4 deletions
diff --git a/src/stores/ServicesStore.js b/src/stores/ServicesStore.js
index 64e6bb42b..2ddeeffd4 100644
--- a/src/stores/ServicesStore.js
+++ b/src/stores/ServicesStore.js
@@ -296,9 +296,12 @@ export default class ServicesStore extends Store {
296 } 296 }
297 297
298 if (service.isNotificationEnabled) { 298 if (service.isNotificationEnabled) {
299 const title = typeof args[0].title === 'string' ? args[0].title : service.name;
300 options.body = typeof options.body === 'string' ? options.body : '';
301
299 this.actions.app.notify({ 302 this.actions.app.notify({
300 notificationId: args[0].notificationId, 303 notificationId: args[0].notificationId,
301 title: args[0].title, 304 title,
302 options, 305 options,
303 serviceId, 306 serviceId,
304 }); 307 });
diff --git a/src/webview/lib/RecipeWebview.js b/src/webview/lib/RecipeWebview.js
index 1787f85e2..b8acc1258 100644
--- a/src/webview/lib/RecipeWebview.js
+++ b/src/webview/lib/RecipeWebview.js
@@ -64,6 +64,12 @@ class RecipeWebview {
64 }); 64 });
65 } 65 }
66 66
67 onNotify(fn) {
68 if (typeof fn === 'function') {
69 window.Notification.onNotify = fn;
70 }
71 }
72
67 initialize(fn) { 73 initialize(fn) {
68 if (typeof fn === 'function') { 74 if (typeof fn === 'function') {
69 fn(); 75 fn();
diff --git a/src/webview/notifications.js b/src/webview/notifications.js
index 97ce9d69b..b3397148d 100644
--- a/src/webview/notifications.js
+++ b/src/webview/notifications.js
@@ -7,13 +7,13 @@ class Notification {
7 this.title = title; 7 this.title = title;
8 this.options = options; 8 this.options = options;
9 this.notificationId = uuidV1(); 9 this.notificationId = uuidV1();
10 this.onclick = () => {}; 10 this.onclick = () => { };
11 11
12 ipcRenderer.sendToHost('notification', { 12 ipcRenderer.sendToHost('notification', Notification.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.on(`notification-onclick:${this.notificationId}`, () => {
19 this.onclick(); 19 this.onclick();
@@ -42,4 +42,6 @@ Notification.close = () => {
42 // no implementation yet 42 // no implementation yet
43}; 43};
44 44
45Notification.onNotify = data => data;
46
45window.Notification = Notification; 47window.Notification = Notification;