aboutsummaryrefslogtreecommitdiffstats
path: root/src/stores/AppStore.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/stores/AppStore.js')
-rw-r--r--src/stores/AppStore.js41
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';
2import { action, observable } from 'mobx'; 2import { action, observable } from 'mobx';
3import moment from 'moment'; 3import moment from 'moment';
4import key from 'keymaster'; 4import key from 'keymaster';
5// import path from 'path'; 5import { getDoNotDisturb } from '@meetfranz/electron-notification-state';
6import idleTimer from '@paulcbetts/system-idle-time'; 6import idleTimer from '@paulcbetts/system-idle-time';
7import AutoLaunch from 'auto-launch'; 7import AutoLaunch from 'auto-launch';
8 8
9import Store from './lib/Store'; 9import Store from './lib/Store';
10import Request from './lib/Request'; 10import Request from './lib/Request';
11import { CHECK_INTERVAL } from '../config'; 11import { CHECK_INTERVAL, DEFAULT_APP_SETTINGS } from '../config';
12import { isMac } from '../environment'; 12import { isMac } from '../environment';
13import locales from '../i18n/translations'; 13import locales from '../i18n/translations';
14import { gaEvent } from '../lib/analytics'; 14import { gaEvent } from '../lib/analytics';
15import Miner from '../lib/Miner'; 15import Miner from '../lib/Miner';
16 16
17const { app, powerMonitor } = remote; 17const { app, powerMonitor } = remote;
18const defaultLocale = 'en-US'; 18const defaultLocale = DEFAULT_APP_SETTINGS.locale;
19const autoLauncher = new AutoLaunch({ 19const 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}