diff options
Diffstat (limited to 'src/stores/ServicesStore.js')
-rw-r--r-- | src/stores/ServicesStore.js | 41 |
1 files changed, 38 insertions, 3 deletions
diff --git a/src/stores/ServicesStore.js b/src/stores/ServicesStore.js index 76e2e538b..9af5d81da 100644 --- a/src/stores/ServicesStore.js +++ b/src/stores/ServicesStore.js | |||
@@ -37,6 +37,7 @@ export default class ServicesStore extends Store { | |||
37 | this.actions.service.toggleService.listen(this._toggleService.bind(this)); | 37 | this.actions.service.toggleService.listen(this._toggleService.bind(this)); |
38 | this.actions.service.handleIPCMessage.listen(this._handleIPCMessage.bind(this)); | 38 | this.actions.service.handleIPCMessage.listen(this._handleIPCMessage.bind(this)); |
39 | this.actions.service.sendIPCMessage.listen(this._sendIPCMessage.bind(this)); | 39 | this.actions.service.sendIPCMessage.listen(this._sendIPCMessage.bind(this)); |
40 | this.actions.service.sendIPCMessageToAllServices.listen(this._sendIPCMessageToAllServices.bind(this)); | ||
40 | this.actions.service.setUnreadMessageCount.listen(this._setUnreadMessageCount.bind(this)); | 41 | this.actions.service.setUnreadMessageCount.listen(this._setUnreadMessageCount.bind(this)); |
41 | this.actions.service.openWindow.listen(this._openWindow.bind(this)); | 42 | this.actions.service.openWindow.listen(this._openWindow.bind(this)); |
42 | this.actions.service.filter.listen(this._filter.bind(this)); | 43 | this.actions.service.filter.listen(this._filter.bind(this)); |
@@ -48,6 +49,7 @@ export default class ServicesStore extends Store { | |||
48 | this.actions.service.reloadUpdatedServices.listen(this._reloadUpdatedServices.bind(this)); | 49 | this.actions.service.reloadUpdatedServices.listen(this._reloadUpdatedServices.bind(this)); |
49 | this.actions.service.reorder.listen(this._reorder.bind(this)); | 50 | this.actions.service.reorder.listen(this._reorder.bind(this)); |
50 | this.actions.service.toggleNotifications.listen(this._toggleNotifications.bind(this)); | 51 | this.actions.service.toggleNotifications.listen(this._toggleNotifications.bind(this)); |
52 | this.actions.service.toggleAudio.listen(this._toggleAudio.bind(this)); | ||
51 | this.actions.service.openDevTools.listen(this._openDevTools.bind(this)); | 53 | this.actions.service.openDevTools.listen(this._openDevTools.bind(this)); |
52 | this.actions.service.openDevToolsForActiveService.listen(this._openDevToolsForActiveService.bind(this)); | 54 | this.actions.service.openDevToolsForActiveService.listen(this._openDevToolsForActiveService.bind(this)); |
53 | 55 | ||
@@ -57,6 +59,7 @@ export default class ServicesStore extends Store { | |||
57 | this._mapActiveServiceToServiceModelReaction.bind(this), | 59 | this._mapActiveServiceToServiceModelReaction.bind(this), |
58 | this._saveActiveService.bind(this), | 60 | this._saveActiveService.bind(this), |
59 | this._logoutReaction.bind(this), | 61 | this._logoutReaction.bind(this), |
62 | this._shareSettingsWithServiceProcess.bind(this), | ||
60 | ]); | 63 | ]); |
61 | 64 | ||
62 | // Just bind this | 65 | // Just bind this |
@@ -283,6 +286,7 @@ export default class ServicesStore extends Store { | |||
283 | if (channel === 'hello') { | 286 | if (channel === 'hello') { |
284 | this._initRecipePolling(service.id); | 287 | this._initRecipePolling(service.id); |
285 | this._initializeServiceRecipeInWebview(serviceId); | 288 | this._initializeServiceRecipeInWebview(serviceId); |
289 | this._shareSettingsWithServiceProcess(); | ||
286 | } else if (channel === 'messages') { | 290 | } else if (channel === 'messages') { |
287 | this.actions.service.setUnreadMessageCount({ | 291 | this.actions.service.setUnreadMessageCount({ |
288 | serviceId, | 292 | serviceId, |
@@ -293,7 +297,7 @@ export default class ServicesStore extends Store { | |||
293 | }); | 297 | }); |
294 | } else if (channel === 'notification') { | 298 | } else if (channel === 'notification') { |
295 | const options = args[0].options; | 299 | const options = args[0].options; |
296 | if (service.recipe.hasNotificationSound) { | 300 | if (service.recipe.hasNotificationSound || service.isMuted) { |
297 | Object.assign(options, { | 301 | Object.assign(options, { |
298 | silent: true, | 302 | silent: true, |
299 | }); | 303 | }); |
@@ -329,7 +333,17 @@ export default class ServicesStore extends Store { | |||
329 | @action _sendIPCMessage({ serviceId, channel, args }) { | 333 | @action _sendIPCMessage({ serviceId, channel, args }) { |
330 | const service = this.one(serviceId); | 334 | const service = this.one(serviceId); |
331 | 335 | ||
332 | service.webview.send(channel, args); | 336 | if (service.webview) { |
337 | service.webview.send(channel, args); | ||
338 | } | ||
339 | } | ||
340 | |||
341 | @action _sendIPCMessageToAllServices({ channel, args }) { | ||
342 | this.all.forEach(s => this.actions.service.sendIPCMessage({ | ||
343 | serviceId: s.id, | ||
344 | channel, | ||
345 | args, | ||
346 | })); | ||
333 | } | 347 | } |
334 | 348 | ||
335 | @action _openWindow({ event }) { | 349 | @action _openWindow({ event }) { |
@@ -405,11 +419,25 @@ export default class ServicesStore extends Store { | |||
405 | @action _toggleNotifications({ serviceId }) { | 419 | @action _toggleNotifications({ serviceId }) { |
406 | const service = this.one(serviceId); | 420 | const service = this.one(serviceId); |
407 | 421 | ||
422 | this.actions.service.updateService({ | ||
423 | serviceId, | ||
424 | serviceData: { | ||
425 | isNotificationEnabled: !service.isNotificationEnabled, | ||
426 | }, | ||
427 | redirect: false, | ||
428 | }); | ||
429 | } | ||
430 | |||
431 | @action _toggleAudio({ serviceId }) { | ||
432 | const service = this.one(serviceId); | ||
433 | |||
408 | service.isNotificationEnabled = !service.isNotificationEnabled; | 434 | service.isNotificationEnabled = !service.isNotificationEnabled; |
409 | 435 | ||
410 | this.actions.service.updateService({ | 436 | this.actions.service.updateService({ |
411 | serviceId, | 437 | serviceId, |
412 | serviceData: service, | 438 | serviceData: { |
439 | isMuted: !service.isMuted, | ||
440 | }, | ||
413 | redirect: false, | 441 | redirect: false, |
414 | }); | 442 | }); |
415 | } | 443 | } |
@@ -480,6 +508,13 @@ export default class ServicesStore extends Store { | |||
480 | } | 508 | } |
481 | } | 509 | } |
482 | 510 | ||
511 | _shareSettingsWithServiceProcess() { | ||
512 | this.actions.service.sendIPCMessageToAllServices({ | ||
513 | channel: 'settings-update', | ||
514 | args: this.stores.settings.all, | ||
515 | }); | ||
516 | } | ||
517 | |||
483 | _cleanUpTeamIdAndCustomUrl(recipeId, data) { | 518 | _cleanUpTeamIdAndCustomUrl(recipeId, data) { |
484 | const serviceData = data; | 519 | const serviceData = data; |
485 | const recipe = this.stores.recipes.one(recipeId); | 520 | const recipe = this.stores.recipes.one(recipeId); |