diff options
Diffstat (limited to 'src/stores/AppStore.js')
-rw-r--r-- | src/stores/AppStore.js | 37 |
1 files changed, 27 insertions, 10 deletions
diff --git a/src/stores/AppStore.js b/src/stores/AppStore.js index 4ac8325d4..38edff1b4 100644 --- a/src/stores/AppStore.js +++ b/src/stores/AppStore.js | |||
@@ -15,8 +15,12 @@ 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 | ||
22 | const mainWindow = remote.getCurrentWindow(); | ||
23 | |||
20 | const defaultLocale = DEFAULT_APP_SETTINGS.locale; | 24 | const defaultLocale = DEFAULT_APP_SETTINGS.locale; |
21 | const autoLauncher = new AutoLaunch({ | 25 | const autoLauncher = new AutoLaunch({ |
22 | name: 'Franz', | 26 | name: 'Franz', |
@@ -48,6 +52,8 @@ export default class AppStore extends Store { | |||
48 | 52 | ||
49 | @observable isClearingAllCache = false; | 53 | @observable isClearingAllCache = false; |
50 | 54 | ||
55 | @observable isFullScreen = mainWindow.isFullScreen(); | ||
56 | |||
51 | constructor(...args) { | 57 | constructor(...args) { |
52 | super(...args); | 58 | super(...args); |
53 | 59 | ||
@@ -80,6 +86,10 @@ export default class AppStore extends Store { | |||
80 | window.addEventListener('online', () => { this.isOnline = true; }); | 86 | window.addEventListener('online', () => { this.isOnline = true; }); |
81 | window.addEventListener('offline', () => { this.isOnline = false; }); | 87 | window.addEventListener('offline', () => { this.isOnline = false; }); |
82 | 88 | ||
89 | mainWindow.on('enter-full-screen', () => { this.isFullScreen = true; }); | ||
90 | mainWindow.on('leave-full-screen', () => { this.isFullScreen = false; }); | ||
91 | |||
92 | |||
83 | this.isOnline = navigator.onLine; | 93 | this.isOnline = navigator.onLine; |
84 | 94 | ||
85 | // Check if Franz should launch on start | 95 | // Check if Franz should launch on start |
@@ -157,7 +167,7 @@ export default class AppStore extends Store { | |||
157 | 167 | ||
158 | // Actions | 168 | // Actions |
159 | @action _notify({ title, options, notificationId, serviceId = null }) { | 169 | @action _notify({ title, options, notificationId, serviceId = null }) { |
160 | if (this.stores.settings.all.isAppMuted) return; | 170 | if (this.stores.settings.all.app.isAppMuted) return; |
161 | 171 | ||
162 | const notification = new window.Notification(title, options); | 172 | const notification = new window.Notification(title, options); |
163 | notification.onclick = (e) => { | 173 | notification.onclick = (e) => { |
@@ -170,8 +180,6 @@ export default class AppStore extends Store { | |||
170 | 180 | ||
171 | this.actions.service.setActive({ serviceId }); | 181 | this.actions.service.setActive({ serviceId }); |
172 | 182 | ||
173 | const mainWindow = remote.getCurrentWindow(); | ||
174 | |||
175 | if (isWindows) { | 183 | if (isWindows) { |
176 | mainWindow.restore(); | 184 | mainWindow.restore(); |
177 | } else if (isLinux) { | 185 | } else if (isLinux) { |
@@ -238,14 +246,15 @@ export default class AppStore extends Store { | |||
238 | this.isSystemMuteOverridden = overrideSystemMute; | 246 | this.isSystemMuteOverridden = overrideSystemMute; |
239 | 247 | ||
240 | this.actions.settings.update({ | 248 | this.actions.settings.update({ |
241 | settings: { | 249 | type: 'app', |
250 | data: { | ||
242 | isAppMuted: isMuted, | 251 | isAppMuted: isMuted, |
243 | }, | 252 | }, |
244 | }); | 253 | }); |
245 | } | 254 | } |
246 | 255 | ||
247 | @action _toggleMuteApp() { | 256 | @action _toggleMuteApp() { |
248 | this._muteApp({ isMuted: !this.stores.settings.all.isAppMuted }); | 257 | this._muteApp({ isMuted: !this.stores.settings.all.app.isAppMuted }); |
249 | } | 258 | } |
250 | 259 | ||
251 | @action async _clearAllCache() { | 260 | @action async _clearAllCache() { |
@@ -279,13 +288,19 @@ export default class AppStore extends Store { | |||
279 | } | 288 | } |
280 | 289 | ||
281 | _setLocale() { | 290 | _setLocale() { |
282 | 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 | |||
283 | 296 | ||
284 | if (locale && Object.prototype.hasOwnProperty.call(locales, locale) && locale !== this.locale) { | 297 | if (locale && Object.prototype.hasOwnProperty.call(locales, locale) && locale !== this.locale) { |
285 | this.locale = locale; | 298 | this.locale = locale; |
286 | } else if (!locale) { | 299 | } else if (!locale) { |
287 | this.locale = this._getDefaultLocale(); | 300 | this.locale = this._getDefaultLocale(); |
288 | } | 301 | } |
302 | |||
303 | debug(`Set locale to "${this.locale}"`); | ||
289 | } | 304 | } |
290 | 305 | ||
291 | _getDefaultLocale() { | 306 | _getDefaultLocale() { |
@@ -327,8 +342,9 @@ export default class AppStore extends Store { | |||
327 | // Helpers | 342 | // Helpers |
328 | _appStartsCounter() { | 343 | _appStartsCounter() { |
329 | this.actions.settings.update({ | 344 | this.actions.settings.update({ |
330 | settings: { | 345 | type: 'stats', |
331 | appStarts: (this.stores.settings.all.appStarts || 0) + 1, | 346 | data: { |
347 | appStarts: (this.stores.settings.all.stats.appStarts || 0) + 1, | ||
332 | }, | 348 | }, |
333 | }); | 349 | }); |
334 | } | 350 | } |
@@ -336,7 +352,8 @@ export default class AppStore extends Store { | |||
336 | async _autoStart() { | 352 | async _autoStart() { |
337 | this.autoLaunchOnStart = await this._checkAutoStart(); | 353 | this.autoLaunchOnStart = await this._checkAutoStart(); |
338 | 354 | ||
339 | if (this.stores.settings.all.appStarts === 1) { | 355 | if (this.stores.settings.all.stats.appStarts === 1) { |
356 | debug('Set app to launch on start'); | ||
340 | this.actions.app.launchOnStartup({ | 357 | this.actions.app.launchOnStartup({ |
341 | enable: true, | 358 | enable: true, |
342 | }); | 359 | }); |
@@ -349,7 +366,7 @@ export default class AppStore extends Store { | |||
349 | 366 | ||
350 | _systemDND() { | 367 | _systemDND() { |
351 | const dnd = getDoNotDisturb(); | 368 | const dnd = getDoNotDisturb(); |
352 | if (dnd !== this.stores.settings.all.isAppMuted && !this.isSystemMuteOverridden) { | 369 | if (dnd !== this.stores.settings.all.app.isAppMuted && !this.isSystemMuteOverridden) { |
353 | this.actions.app.muteApp({ | 370 | this.actions.app.muteApp({ |
354 | isMuted: dnd, | 371 | isMuted: dnd, |
355 | overrideSystemMute: false, | 372 | overrideSystemMute: false, |