Skip to content

Commit

Permalink
fix(App): Allow to turn on notifications when system dnd is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
adlk committed Nov 29, 2017
1 parent 0fa1caf commit 3045b47
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/actions/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export default {
healthCheck: {},
muteApp: {
isMuted: PropTypes.bool.isRequired,
overrideSystemMute: PropTypes.bool,
},
toggleMuteApp: {},
};
6 changes: 2 additions & 4 deletions src/containers/layout/AppLayoutContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,11 @@ export default class AppLayoutContainer extends Component {
);
}

const isMuted = settings.all.isAppMuted || app.isSystemMuted;

const sidebar = (
<Sidebar
services={services.allDisplayed}
setActive={setActive}
isAppMuted={isMuted}
isAppMuted={settings.all.isAppMuted}
openSettings={openSettings}
closeSettings={closeSettings}
reorder={reorder}
Expand All @@ -99,7 +97,7 @@ export default class AppLayoutContainer extends Component {
setWebviewReference={setWebviewReference}
openWindow={openWindow}
reload={reload}
isAppMuted={isMuted}
isAppMuted={settings.all.isAppMuted}
update={updateService}
/>
);
Expand Down
14 changes: 11 additions & 3 deletions src/stores/AppStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
});
}
}
}
3 changes: 2 additions & 1 deletion src/stores/SettingsStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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 }) {
Expand Down

0 comments on commit 3045b47

Please sign in to comment.