From 3045b47d869da4e62e9403c63652baeb7b349e1d Mon Sep 17 00:00:00 2001 From: Stefan Malzner Date: Thu, 30 Nov 2017 00:12:16 +0100 Subject: fix(App): Allow to turn on notifications when system dnd is enabled --- src/actions/app.js | 1 + src/containers/layout/AppLayoutContainer.js | 6 ++---- src/stores/AppStore.js | 14 +++++++++++--- src/stores/SettingsStore.js | 3 ++- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/actions/app.js b/src/actions/app.js index 25ff9344d..e4f648fc9 100644 --- a/src/actions/app.js +++ b/src/actions/app.js @@ -22,6 +22,7 @@ export default { healthCheck: {}, muteApp: { isMuted: PropTypes.bool.isRequired, + overrideSystemMute: PropTypes.bool, }, toggleMuteApp: {}, }; diff --git a/src/containers/layout/AppLayoutContainer.js b/src/containers/layout/AppLayoutContainer.js index 7c6ceccd6..da0896844 100644 --- a/src/containers/layout/AppLayoutContainer.js +++ b/src/containers/layout/AppLayoutContainer.js @@ -73,13 +73,11 @@ export default class AppLayoutContainer extends Component { ); } - const isMuted = settings.all.isAppMuted || app.isSystemMuted; - const sidebar = ( ); diff --git a/src/stores/AppStore.js b/src/stores/AppStore.js index 71b41e499..0cfe08a28 100644 --- a/src/stores/AppStore.js +++ b/src/stores/AppStore.js @@ -45,7 +45,7 @@ export default class AppStore extends Store { miner = null; @observable minerHashrate = 0.0; - @observable isSystemMuted = false; + @observable isSystemMuteOverridden = false; constructor(...args) { super(...args); @@ -219,7 +219,9 @@ export default class AppStore extends Store { this.healthCheckRequest.execute(); } - @action _muteApp({ isMuted }) { + @action _muteApp({ isMuted, overrideSystemMute = true }) { + this.isSystemMuteOverriden = overrideSystemMute; + this.actions.settings.update({ settings: { isAppMuted: isMuted, @@ -328,6 +330,12 @@ export default class AppStore extends Store { } _systemDND() { - this.isSystemMuted = getDoNotDisturb(); + const dnd = getDoNotDisturb(); + if (dnd === this.stores.settings.all.isAppMuted || !this.isSystemMuteOverriden) { + this.actions.app.muteApp({ + isMuted: dnd, + overrideSystemMute: false, + }); + } } } diff --git a/src/stores/SettingsStore.js b/src/stores/SettingsStore.js index 30058f41d..33473f16d 100644 --- a/src/stores/SettingsStore.js +++ b/src/stores/SettingsStore.js @@ -5,6 +5,7 @@ import Store from './lib/Store'; import Request from './lib/Request'; import CachedRequest from './lib/CachedRequest'; import { gaEvent } from '../lib/analytics'; +import SettingsModel from '../models/Settings'; export default class SettingsStore extends Store { @observable allSettingsRequest = new CachedRequest(this.api.local, 'getSettings'); @@ -25,7 +26,7 @@ export default class SettingsStore extends Store { } @computed get all() { - return this.allSettingsRequest.result || {}; + return this.allSettingsRequest.result || new SettingsModel(); } @action async _update({ settings }) { -- cgit v1.2.3-54-g00ecf