diff options
author | Stefan Malzner <stefan@adlk.io> | 2017-11-23 16:17:34 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-23 16:17:34 +0100 |
commit | abca425e4a7b63be93132067bc335e8b6b39c2b2 (patch) | |
tree | e386f3e5d4c1c1caff19e3555e7ed1ce93e625f6 /src/stores/AppStore.js | |
parent | replace typeform (diff) | |
parent | Add windows notification fix to changelog (diff) | |
download | ferdium-app-abca425e4a7b63be93132067bc335e8b6b39c2b2.tar.gz ferdium-app-abca425e4a7b63be93132067bc335e8b6b39c2b2.tar.zst ferdium-app-abca425e4a7b63be93132067bc335e8b6b39c2b2.zip |
Merge pull request #330 from meetfranz/developv5.0.0-beta.14
Beta 14
Diffstat (limited to 'src/stores/AppStore.js')
-rw-r--r-- | src/stores/AppStore.js | 41 |
1 files changed, 36 insertions, 5 deletions
diff --git a/src/stores/AppStore.js b/src/stores/AppStore.js index ecfd621d3..0b7c60bce 100644 --- a/src/stores/AppStore.js +++ b/src/stores/AppStore.js | |||
@@ -2,20 +2,20 @@ 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 | ||
9 | import Store from './lib/Store'; | 9 | import Store from './lib/Store'; |
10 | import Request from './lib/Request'; | 10 | import Request from './lib/Request'; |
11 | import { CHECK_INTERVAL } from '../config'; | 11 | import { CHECK_INTERVAL, DEFAULT_APP_SETTINGS } from '../config'; |
12 | import { isMac } from '../environment'; | 12 | import { isMac } from '../environment'; |
13 | import locales from '../i18n/translations'; | 13 | import locales from '../i18n/translations'; |
14 | import { gaEvent } from '../lib/analytics'; | 14 | import { gaEvent } from '../lib/analytics'; |
15 | import Miner from '../lib/Miner'; | 15 | import Miner from '../lib/Miner'; |
16 | 16 | ||
17 | const { app, powerMonitor } = remote; | 17 | const { app, powerMonitor } = remote; |
18 | const defaultLocale = 'en-US'; | 18 | const defaultLocale = DEFAULT_APP_SETTINGS.locale; |
19 | const autoLauncher = new AutoLaunch({ | 19 | const autoLauncher = new AutoLaunch({ |
20 | name: 'Franz', | 20 | name: 'Franz', |
21 | }); | 21 | }); |
@@ -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) |
@@ -118,16 +127,22 @@ export default class AppStore extends Store { | |||
118 | 127 | ||
119 | // Set active the next service | 128 | // Set active the next service |
120 | key( | 129 | key( |
121 | '⌘+pagedown, ctrl+pagedown, ⌘+tab, ctrl+tab', () => { | 130 | '⌘+pagedown, ctrl+pagedown, ⌘+alt+right, ctrl+tab', () => { |
122 | this.actions.service.setActiveNext(); | 131 | this.actions.service.setActiveNext(); |
123 | }); | 132 | }); |
124 | 133 | ||
125 | // Set active the prev service | 134 | // Set active the prev service |
126 | key( | 135 | key( |
127 | '⌘+pageup, ctrl+pageup, ⌘+shift+tab, ctrl+shift+tab', () => { | 136 | '⌘+pageup, ctrl+pageup, ⌘+alt+left, ctrl+shift+tab', () => { |
128 | this.actions.service.setActivePrev(); | 137 | this.actions.service.setActivePrev(); |
129 | }); | 138 | }); |
130 | 139 | ||
140 | // Global Mute | ||
141 | key( | ||
142 | '⌘+shift+m ctrl+shift+m', () => { | ||
143 | this.actions.app.toggleMuteApp(); | ||
144 | }); | ||
145 | |||
131 | this.locale = this._getDefaultLocale(); | 146 | this.locale = this._getDefaultLocale(); |
132 | 147 | ||
133 | this._healthCheck(); | 148 | this._healthCheck(); |
@@ -202,6 +217,18 @@ export default class AppStore extends Store { | |||
202 | this.healthCheckRequest.execute(); | 217 | this.healthCheckRequest.execute(); |
203 | } | 218 | } |
204 | 219 | ||
220 | @action _muteApp({ isMuted }) { | ||
221 | this.actions.settings.update({ | ||
222 | settings: { | ||
223 | isAppMuted: isMuted, | ||
224 | }, | ||
225 | }); | ||
226 | } | ||
227 | |||
228 | @action _toggleMuteApp() { | ||
229 | this._muteApp({ isMuted: !this.stores.settings.all.isAppMuted }); | ||
230 | } | ||
231 | |||
205 | // Reactions | 232 | // Reactions |
206 | _offlineCheck() { | 233 | _offlineCheck() { |
207 | if (!this.isOnline) { | 234 | if (!this.isOnline) { |
@@ -297,4 +324,8 @@ export default class AppStore extends Store { | |||
297 | async _checkAutoStart() { | 324 | async _checkAutoStart() { |
298 | return autoLauncher.isEnabled() || false; | 325 | return autoLauncher.isEnabled() || false; |
299 | } | 326 | } |
327 | |||
328 | _systemDND() { | ||
329 | this.isSystemMuted = getDoNotDisturb(); | ||
330 | } | ||
300 | } | 331 | } |