diff options
Diffstat (limited to 'src/stores/AppStore.js')
-rw-r--r-- | src/stores/AppStore.js | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/src/stores/AppStore.js b/src/stores/AppStore.js index b3554f9d8..38edff1b4 100644 --- a/src/stores/AppStore.js +++ b/src/stores/AppStore.js | |||
@@ -15,6 +15,8 @@ import { gaEvent } from '../lib/analytics'; | |||
15 | 15 | ||
16 | import { getServiceIdsFromPartitions, removeServicePartitionDirectory } from '../helpers/service-helpers.js'; | 16 | import { getServiceIdsFromPartitions, removeServicePartitionDirectory } from '../helpers/service-helpers.js'; |
17 | 17 | ||
18 | const debug = require('debug')('AppStore'); | ||
19 | |||
18 | const { app } = remote; | 20 | const { app } = remote; |
19 | 21 | ||
20 | const mainWindow = remote.getCurrentWindow(); | 22 | const mainWindow = remote.getCurrentWindow(); |
@@ -165,7 +167,7 @@ export default class AppStore extends Store { | |||
165 | 167 | ||
166 | // Actions | 168 | // Actions |
167 | @action _notify({ title, options, notificationId, serviceId = null }) { | 169 | @action _notify({ title, options, notificationId, serviceId = null }) { |
168 | if (this.stores.settings.all.isAppMuted) return; | 170 | if (this.stores.settings.all.app.isAppMuted) return; |
169 | 171 | ||
170 | const notification = new window.Notification(title, options); | 172 | const notification = new window.Notification(title, options); |
171 | notification.onclick = (e) => { | 173 | notification.onclick = (e) => { |
@@ -244,14 +246,15 @@ export default class AppStore extends Store { | |||
244 | this.isSystemMuteOverridden = overrideSystemMute; | 246 | this.isSystemMuteOverridden = overrideSystemMute; |
245 | 247 | ||
246 | this.actions.settings.update({ | 248 | this.actions.settings.update({ |
247 | settings: { | 249 | type: 'app', |
250 | data: { | ||
248 | isAppMuted: isMuted, | 251 | isAppMuted: isMuted, |
249 | }, | 252 | }, |
250 | }); | 253 | }); |
251 | } | 254 | } |
252 | 255 | ||
253 | @action _toggleMuteApp() { | 256 | @action _toggleMuteApp() { |
254 | this._muteApp({ isMuted: !this.stores.settings.all.isAppMuted }); | 257 | this._muteApp({ isMuted: !this.stores.settings.all.app.isAppMuted }); |
255 | } | 258 | } |
256 | 259 | ||
257 | @action async _clearAllCache() { | 260 | @action async _clearAllCache() { |
@@ -285,13 +288,19 @@ export default class AppStore extends Store { | |||
285 | } | 288 | } |
286 | 289 | ||
287 | _setLocale() { | 290 | _setLocale() { |
288 | const locale = this.stores.settings.all.locale; | 291 | let locale; |
292 | if (this.stores.user.isLoggedIn) { | ||
293 | locale = this.stores.user.data.locale; | ||
294 | } | ||
295 | |||
289 | 296 | ||
290 | if (locale && Object.prototype.hasOwnProperty.call(locales, locale) && locale !== this.locale) { | 297 | if (locale && Object.prototype.hasOwnProperty.call(locales, locale) && locale !== this.locale) { |
291 | this.locale = locale; | 298 | this.locale = locale; |
292 | } else if (!locale) { | 299 | } else if (!locale) { |
293 | this.locale = this._getDefaultLocale(); | 300 | this.locale = this._getDefaultLocale(); |
294 | } | 301 | } |
302 | |||
303 | debug(`Set locale to "${this.locale}"`); | ||
295 | } | 304 | } |
296 | 305 | ||
297 | _getDefaultLocale() { | 306 | _getDefaultLocale() { |
@@ -333,8 +342,9 @@ export default class AppStore extends Store { | |||
333 | // Helpers | 342 | // Helpers |
334 | _appStartsCounter() { | 343 | _appStartsCounter() { |
335 | this.actions.settings.update({ | 344 | this.actions.settings.update({ |
336 | settings: { | 345 | type: 'stats', |
337 | appStarts: (this.stores.settings.all.appStarts || 0) + 1, | 346 | data: { |
347 | appStarts: (this.stores.settings.all.stats.appStarts || 0) + 1, | ||
338 | }, | 348 | }, |
339 | }); | 349 | }); |
340 | } | 350 | } |
@@ -342,7 +352,8 @@ export default class AppStore extends Store { | |||
342 | async _autoStart() { | 352 | async _autoStart() { |
343 | this.autoLaunchOnStart = await this._checkAutoStart(); | 353 | this.autoLaunchOnStart = await this._checkAutoStart(); |
344 | 354 | ||
345 | if (this.stores.settings.all.appStarts === 1) { | 355 | if (this.stores.settings.all.stats.appStarts === 1) { |
356 | debug('Set app to launch on start'); | ||
346 | this.actions.app.launchOnStartup({ | 357 | this.actions.app.launchOnStartup({ |
347 | enable: true, | 358 | enable: true, |
348 | }); | 359 | }); |
@@ -355,7 +366,7 @@ export default class AppStore extends Store { | |||
355 | 366 | ||
356 | _systemDND() { | 367 | _systemDND() { |
357 | const dnd = getDoNotDisturb(); | 368 | const dnd = getDoNotDisturb(); |
358 | if (dnd !== this.stores.settings.all.isAppMuted && !this.isSystemMuteOverridden) { | 369 | if (dnd !== this.stores.settings.all.app.isAppMuted && !this.isSystemMuteOverridden) { |
359 | this.actions.app.muteApp({ | 370 | this.actions.app.muteApp({ |
360 | isMuted: dnd, | 371 | isMuted: dnd, |
361 | overrideSystemMute: false, | 372 | overrideSystemMute: false, |