diff options
Diffstat (limited to 'src/stores/AppStore.js')
-rw-r--r-- | src/stores/AppStore.js | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/src/stores/AppStore.js b/src/stores/AppStore.js index e9faad911..14bdab094 100644 --- a/src/stores/AppStore.js +++ b/src/stores/AppStore.js | |||
@@ -2,7 +2,7 @@ import { remote, ipcRenderer, shell } from 'electron'; | |||
2 | import { action, observable } from 'mobx'; | 2 | import { action, observable } from 'mobx'; |
3 | import moment from 'moment'; | 3 | import moment from 'moment'; |
4 | import key from 'keymaster'; | 4 | import key from 'keymaster'; |
5 | // import path from 'path'; | 5 | import { getDoNotDisturb } from '@meetfranz/electron-notification-state'; |
6 | import idleTimer from '@paulcbetts/system-idle-time'; | 6 | import idleTimer from '@paulcbetts/system-idle-time'; |
7 | import AutoLaunch from 'auto-launch'; | 7 | import AutoLaunch from 'auto-launch'; |
8 | 8 | ||
@@ -45,6 +45,8 @@ export default class AppStore extends Store { | |||
45 | miner = null; | 45 | miner = null; |
46 | @observable minerHashrate = 0.0; | 46 | @observable minerHashrate = 0.0; |
47 | 47 | ||
48 | @observable isSystemMuted = false; | ||
49 | |||
48 | constructor(...args) { | 50 | constructor(...args) { |
49 | super(...args); | 51 | super(...args); |
50 | 52 | ||
@@ -57,6 +59,8 @@ export default class AppStore extends Store { | |||
57 | this.actions.app.installUpdate.listen(this._installUpdate.bind(this)); | 59 | this.actions.app.installUpdate.listen(this._installUpdate.bind(this)); |
58 | this.actions.app.resetUpdateStatus.listen(this._resetUpdateStatus.bind(this)); | 60 | this.actions.app.resetUpdateStatus.listen(this._resetUpdateStatus.bind(this)); |
59 | this.actions.app.healthCheck.listen(this._healthCheck.bind(this)); | 61 | this.actions.app.healthCheck.listen(this._healthCheck.bind(this)); |
62 | this.actions.app.muteApp.listen(this._muteApp.bind(this)); | ||
63 | this.actions.app.toggleMuteApp.listen(this._toggleMuteApp.bind(this)); | ||
60 | 64 | ||
61 | this.registerReactions([ | 65 | this.registerReactions([ |
62 | this._offlineCheck.bind(this), | 66 | this._offlineCheck.bind(this), |
@@ -81,6 +85,11 @@ export default class AppStore extends Store { | |||
81 | // Needs to be delayed a bit | 85 | // Needs to be delayed a bit |
82 | this._autoStart(); | 86 | this._autoStart(); |
83 | 87 | ||
88 | // Check if system is muted | ||
89 | // There are no events to subscribe so we need to poll everey 5s | ||
90 | this._systemDND(); | ||
91 | setInterval(() => this._systemDND(), 5000); | ||
92 | |||
84 | // Check for updates once every 4 hours | 93 | // Check for updates once every 4 hours |
85 | setInterval(() => this._checkForUpdates(), CHECK_INTERVAL); | 94 | setInterval(() => this._checkForUpdates(), CHECK_INTERVAL); |
86 | // Check for an update in 30s (need a delay to prevent Squirrel Installer lock file issues) | 95 | // Check for an update in 30s (need a delay to prevent Squirrel Installer lock file issues) |
@@ -202,6 +211,18 @@ export default class AppStore extends Store { | |||
202 | this.healthCheckRequest.execute(); | 211 | this.healthCheckRequest.execute(); |
203 | } | 212 | } |
204 | 213 | ||
214 | @action _muteApp({ isMuted }) { | ||
215 | this.actions.settings.update({ | ||
216 | settings: { | ||
217 | isMuted, | ||
218 | }, | ||
219 | }); | ||
220 | } | ||
221 | |||
222 | @action _toggleMuteApp() { | ||
223 | this._muteApp({ isMuted: !this.stores.settings.all.isMuted }); | ||
224 | } | ||
225 | |||
205 | // Reactions | 226 | // Reactions |
206 | _offlineCheck() { | 227 | _offlineCheck() { |
207 | if (!this.isOnline) { | 228 | if (!this.isOnline) { |
@@ -297,4 +318,8 @@ export default class AppStore extends Store { | |||
297 | async _checkAutoStart() { | 318 | async _checkAutoStart() { |
298 | return autoLauncher.isEnabled() || false; | 319 | return autoLauncher.isEnabled() || false; |
299 | } | 320 | } |
321 | |||
322 | _systemDND() { | ||
323 | this.isSystemMuted = getDoNotDisturb(); | ||
324 | } | ||
300 | } | 325 | } |