aboutsummaryrefslogtreecommitdiffstats
path: root/src/stores
diff options
context:
space:
mode:
authorLibravatar Stefan Malzner <stefan@adlk.io>2017-12-01 12:26:41 +0100
committerLibravatar Stefan Malzner <stefan@adlk.io>2017-12-01 12:26:41 +0100
commit893a9f6d9a1bcdbbfe925e718b2c907dcceaa64e (patch)
tree4f6ff5c4f82abe536107a38c9894fad7f41a0c62 /src/stores
parentfix(App): Allow to turn on notifications when system dnd is enabled (diff)
downloadferdium-app-893a9f6d9a1bcdbbfe925e718b2c907dcceaa64e.tar.gz
ferdium-app-893a9f6d9a1bcdbbfe925e718b2c907dcceaa64e.tar.zst
ferdium-app-893a9f6d9a1bcdbbfe925e718b2c907dcceaa64e.zip
feat(App): Add option to show/hide notification badges for muted services (@maximiliancsuk)
Diffstat (limited to 'src/stores')
-rw-r--r--src/stores/AppStore.js9
-rw-r--r--src/stores/ServicesStore.js19
-rw-r--r--src/stores/UIStore.js8
3 files changed, 30 insertions, 6 deletions
diff --git a/src/stores/AppStore.js b/src/stores/AppStore.js
index 0cfe08a28..6125a7cff 100644
--- a/src/stores/AppStore.js
+++ b/src/stores/AppStore.js
@@ -67,6 +67,7 @@ export default class AppStore extends Store {
67 this._setLocale.bind(this), 67 this._setLocale.bind(this),
68 this._handleMiner.bind(this), 68 this._handleMiner.bind(this),
69 this._handleMinerThrottle.bind(this), 69 this._handleMinerThrottle.bind(this),
70 this._muteAppHandler.bind(this),
70 ]); 71 ]);
71 } 72 }
72 73
@@ -300,6 +301,14 @@ export default class AppStore extends Store {
300 } 301 }
301 } 302 }
302 303
304 _muteAppHandler() {
305 const showMessageBadgesEvenWhenMuted = this.stores.ui.showMessageBadgesEvenWhenMuted;
306
307 if (!showMessageBadgesEvenWhenMuted) {
308 this.actions.app.setBadge({ unreadDirectMessageCount: 0, unreadIndirectMessageCount: 0 });
309 }
310 }
311
303 // Helpers 312 // Helpers
304 async _appStartsCounter() { 313 async _appStartsCounter() {
305 // we need to wait until the settings request is resolved 314 // we need to wait until the settings request is resolved
diff --git a/src/stores/ServicesStore.js b/src/stores/ServicesStore.js
index 22c376c06..e79677400 100644
--- a/src/stores/ServicesStore.js
+++ b/src/stores/ServicesStore.js
@@ -488,19 +488,28 @@ export default class ServicesStore extends Store {
488 } 488 }
489 489
490 _getUnreadMessageCountReaction() { 490 _getUnreadMessageCountReaction() {
491 const showMessageBadgeWhenMuted = this.stores.settings.all.showMessageBadgeWhenMuted;
492 const showMessageBadgesEvenWhenMuted = this.stores.ui.showMessageBadgesEvenWhenMuted;
493
494 // TODO: unfinished monkey business
495
491 const unreadDirectMessageCount = this.enabled 496 const unreadDirectMessageCount = this.enabled
497 .filter(s => (showMessageBadgeWhenMuted || s.isNotificationEnabled) && showMessageBadgesEvenWhenMuted)
492 .map(s => s.unreadDirectMessageCount) 498 .map(s => s.unreadDirectMessageCount)
493 .reduce((a, b) => a + b, 0); 499 .reduce((a, b) => a + b, 0);
494 500
495 const unreadIndirectMessageCount = this.enabled 501 const unreadIndirectMessageCount = this.enabled
496 .filter(s => s.isIndirectMessageBadgeEnabled) 502 // .filter(s => s.isIndirectMessageBadgeEnabled && (s.isNotificationEnabled && showMessageBadgeWhenMuted))
497 .map(s => s.unreadIndirectMessageCount) 503 .map(s => s.unreadIndirectMessageCount)
498 .reduce((a, b) => a + b, 0); 504 .reduce((a, b) => a + b, 0);
499 505
500 this.actions.app.setBadge({ 506 // We can't just block this earlier, otherwise the mobx reaction won't be aware of the vars to watch in some cases
501 unreadDirectMessageCount, 507 if (showMessageBadgesEvenWhenMuted) {
502 unreadIndirectMessageCount, 508 this.actions.app.setBadge({
503 }); 509 unreadDirectMessageCount,
510 unreadIndirectMessageCount,
511 });
512 }
504 } 513 }
505 514
506 _logoutReaction() { 515 _logoutReaction() {
diff --git a/src/stores/UIStore.js b/src/stores/UIStore.js
index cb45b88b5..5e9cc9ba7 100644
--- a/src/stores/UIStore.js
+++ b/src/stores/UIStore.js
@@ -1,4 +1,4 @@
1import { action, observable } from 'mobx'; 1import { action, observable, computed } from 'mobx';
2 2
3import Store from './lib/Store'; 3import Store from './lib/Store';
4 4
@@ -14,6 +14,12 @@ export default class UIStore extends Store {
14 this.actions.ui.toggleServiceUpdatedInfoBar.listen(this._toggleServiceUpdatedInfoBar.bind(this)); 14 this.actions.ui.toggleServiceUpdatedInfoBar.listen(this._toggleServiceUpdatedInfoBar.bind(this));
15 } 15 }
16 16
17 @computed get showMessageBadgesEvenWhenMuted() {
18 const settings = this.stores.settings.all;
19
20 return (settings.isAppMuted && settings.showMessageBadgeWhenMuted) || !settings.isAppMuted;
21 }
22
17 // Actions 23 // Actions
18 @action _openSettings({ path = '/settings' }) { 24 @action _openSettings({ path = '/settings' }) {
19 const settingsPath = path !== '/settings' ? `/settings/${path}` : path; 25 const settingsPath = path !== '/settings' ? `/settings/${path}` : path;