diff options
Diffstat (limited to 'src/stores/AppStore.js')
-rw-r--r-- | src/stores/AppStore.js | 60 |
1 files changed, 52 insertions, 8 deletions
diff --git a/src/stores/AppStore.js b/src/stores/AppStore.js index 14bdab094..5a6c12ee1 100644 --- a/src/stores/AppStore.js +++ b/src/stores/AppStore.js | |||
@@ -45,7 +45,7 @@ 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; | 48 | @observable isSystemMuteOverridden = false; |
49 | 49 | ||
50 | constructor(...args) { | 50 | constructor(...args) { |
51 | super(...args); | 51 | super(...args); |
@@ -67,6 +67,7 @@ export default class AppStore extends Store { | |||
67 | this._setLocale.bind(this), | 67 | this._setLocale.bind(this), |
68 | this._handleMiner.bind(this), | 68 | this._handleMiner.bind(this), |
69 | this._handleMinerThrottle.bind(this), | 69 | this._handleMinerThrottle.bind(this), |
70 | this._muteAppHandler.bind(this), | ||
70 | ]); | 71 | ]); |
71 | } | 72 | } |
72 | 73 | ||
@@ -115,6 +116,14 @@ export default class AppStore extends Store { | |||
115 | } | 116 | } |
116 | }); | 117 | }); |
117 | 118 | ||
119 | // Handle deep linking (franz://) | ||
120 | ipcRenderer.on('navigateFromDeepLink', (event, data) => { | ||
121 | const { url } = data; | ||
122 | if (!url) return; | ||
123 | |||
124 | this.stores.router.push(data.url); | ||
125 | }); | ||
126 | |||
118 | // Check system idle time every minute | 127 | // Check system idle time every minute |
119 | setInterval(() => { | 128 | setInterval(() => { |
120 | this.idleTime = idleTimer.getIdleTime(); | 129 | this.idleTime = idleTimer.getIdleTime(); |
@@ -127,16 +136,22 @@ export default class AppStore extends Store { | |||
127 | 136 | ||
128 | // Set active the next service | 137 | // Set active the next service |
129 | key( | 138 | key( |
130 | '⌘+pagedown, ctrl+pagedown, ⌘+tab, ctrl+tab', () => { | 139 | '⌘+pagedown, ctrl+pagedown, ⌘+alt+right, ctrl+tab', () => { |
131 | this.actions.service.setActiveNext(); | 140 | this.actions.service.setActiveNext(); |
132 | }); | 141 | }); |
133 | 142 | ||
134 | // Set active the prev service | 143 | // Set active the prev service |
135 | key( | 144 | key( |
136 | '⌘+pageup, ctrl+pageup, ⌘+shift+tab, ctrl+shift+tab', () => { | 145 | '⌘+pageup, ctrl+pageup, ⌘+alt+left, ctrl+shift+tab', () => { |
137 | this.actions.service.setActivePrev(); | 146 | this.actions.service.setActivePrev(); |
138 | }); | 147 | }); |
139 | 148 | ||
149 | // Global Mute | ||
150 | key( | ||
151 | '⌘+shift+m ctrl+shift+m', () => { | ||
152 | this.actions.app.toggleMuteApp(); | ||
153 | }); | ||
154 | |||
140 | this.locale = this._getDefaultLocale(); | 155 | this.locale = this._getDefaultLocale(); |
141 | 156 | ||
142 | this._healthCheck(); | 157 | this._healthCheck(); |
@@ -144,6 +159,8 @@ export default class AppStore extends Store { | |||
144 | 159 | ||
145 | // Actions | 160 | // Actions |
146 | @action _notify({ title, options, notificationId, serviceId = null }) { | 161 | @action _notify({ title, options, notificationId, serviceId = null }) { |
162 | if (this.stores.settings.all.isAppMuted) return; | ||
163 | |||
147 | const notification = new window.Notification(title, options); | 164 | const notification = new window.Notification(title, options); |
148 | notification.onclick = (e) => { | 165 | notification.onclick = (e) => { |
149 | if (serviceId) { | 166 | if (serviceId) { |
@@ -154,6 +171,11 @@ export default class AppStore extends Store { | |||
154 | }); | 171 | }); |
155 | 172 | ||
156 | this.actions.service.setActive({ serviceId }); | 173 | this.actions.service.setActive({ serviceId }); |
174 | |||
175 | if (!isMac) { | ||
176 | const mainWindow = remote.getCurrentWindow(); | ||
177 | mainWindow.restore(); | ||
178 | } | ||
157 | } | 179 | } |
158 | }; | 180 | }; |
159 | } | 181 | } |
@@ -211,16 +233,18 @@ export default class AppStore extends Store { | |||
211 | this.healthCheckRequest.execute(); | 233 | this.healthCheckRequest.execute(); |
212 | } | 234 | } |
213 | 235 | ||
214 | @action _muteApp({ isMuted }) { | 236 | @action _muteApp({ isMuted, overrideSystemMute = true }) { |
237 | this.isSystemMuteOverriden = overrideSystemMute; | ||
238 | |||
215 | this.actions.settings.update({ | 239 | this.actions.settings.update({ |
216 | settings: { | 240 | settings: { |
217 | isMuted, | 241 | isAppMuted: isMuted, |
218 | }, | 242 | }, |
219 | }); | 243 | }); |
220 | } | 244 | } |
221 | 245 | ||
222 | @action _toggleMuteApp() { | 246 | @action _toggleMuteApp() { |
223 | this._muteApp({ isMuted: !this.stores.settings.all.isMuted }); | 247 | this._muteApp({ isMuted: !this.stores.settings.all.isAppMuted }); |
224 | } | 248 | } |
225 | 249 | ||
226 | // Reactions | 250 | // Reactions |
@@ -239,8 +263,10 @@ export default class AppStore extends Store { | |||
239 | _setLocale() { | 263 | _setLocale() { |
240 | const locale = this.stores.settings.all.locale; | 264 | const locale = this.stores.settings.all.locale; |
241 | 265 | ||
242 | if (locale && locale !== this.locale) { | 266 | if (locale && Object.prototype.hasOwnProperty.call(locales, locale) && locale !== this.locale) { |
243 | this.locale = locale; | 267 | this.locale = locale; |
268 | } else if (!locale) { | ||
269 | this.locale = this._getDefaultLocale(); | ||
244 | } | 270 | } |
245 | } | 271 | } |
246 | 272 | ||
@@ -265,6 +291,10 @@ export default class AppStore extends Store { | |||
265 | locale = defaultLocale; | 291 | locale = defaultLocale; |
266 | } | 292 | } |
267 | 293 | ||
294 | if (!locale) { | ||
295 | locale = DEFAULT_APP_SETTINGS.fallbackLocale; | ||
296 | } | ||
297 | |||
268 | return locale; | 298 | return locale; |
269 | } | 299 | } |
270 | 300 | ||
@@ -290,6 +320,14 @@ export default class AppStore extends Store { | |||
290 | } | 320 | } |
291 | } | 321 | } |
292 | 322 | ||
323 | _muteAppHandler() { | ||
324 | const showMessageBadgesEvenWhenMuted = this.stores.ui.showMessageBadgesEvenWhenMuted; | ||
325 | |||
326 | if (!showMessageBadgesEvenWhenMuted) { | ||
327 | this.actions.app.setBadge({ unreadDirectMessageCount: 0, unreadIndirectMessageCount: 0 }); | ||
328 | } | ||
329 | } | ||
330 | |||
293 | // Helpers | 331 | // Helpers |
294 | async _appStartsCounter() { | 332 | async _appStartsCounter() { |
295 | // we need to wait until the settings request is resolved | 333 | // we need to wait until the settings request is resolved |
@@ -320,6 +358,12 @@ export default class AppStore extends Store { | |||
320 | } | 358 | } |
321 | 359 | ||
322 | _systemDND() { | 360 | _systemDND() { |
323 | this.isSystemMuted = getDoNotDisturb(); | 361 | const dnd = getDoNotDisturb(); |
362 | if (dnd === this.stores.settings.all.isAppMuted || !this.isSystemMuteOverriden) { | ||
363 | this.actions.app.muteApp({ | ||
364 | isMuted: dnd, | ||
365 | overrideSystemMute: false, | ||
366 | }); | ||
367 | } | ||
324 | } | 368 | } |
325 | } | 369 | } |