aboutsummaryrefslogtreecommitdiffstats
path: root/src/stores/AppStore.js
diff options
context:
space:
mode:
authorLibravatar Markus Hatvan <markus_hatvan@aon.at>2021-10-07 08:04:11 +0200
committerLibravatar GitHub <noreply@github.com>2021-10-07 08:04:11 +0200
commit4898ff4a6a7bfc83a10ddc2f32abb2da82f4819f (patch)
treef17e2b06ab8c8c49ff428134a433e957b26ac0c0 /src/stores/AppStore.js
parentchore: upgrade react to latest (#2030) (diff)
downloadferdium-app-4898ff4a6a7bfc83a10ddc2f32abb2da82f4819f.tar.gz
ferdium-app-4898ff4a6a7bfc83a10ddc2f32abb2da82f4819f.tar.zst
ferdium-app-4898ff4a6a7bfc83a10ddc2f32abb2da82f4819f.zip
refactor: locale selection cleanup (#2031)
Diffstat (limited to 'src/stores/AppStore.js')
-rw-r--r--src/stores/AppStore.js47
1 files changed, 14 insertions, 33 deletions
diff --git a/src/stores/AppStore.js b/src/stores/AppStore.js
index 3d9d2b551..a86a54c6d 100644
--- a/src/stores/AppStore.js
+++ b/src/stores/AppStore.js
@@ -17,16 +17,8 @@ import { readJsonSync } from 'fs-extra';
17import Store from './lib/Store'; 17import Store from './lib/Store';
18import Request from './lib/Request'; 18import Request from './lib/Request';
19import { CHECK_INTERVAL, DEFAULT_APP_SETTINGS } from '../config'; 19import { CHECK_INTERVAL, DEFAULT_APP_SETTINGS } from '../config';
20import { 20import { isMac, electronVersion, osRelease } from '../environment';
21 isMac, 21import { ferdiVersion, userDataPath, ferdiLocale } from '../environment-remote';
22 electronVersion,
23 osRelease,
24} from '../environment';
25import {
26 ferdiVersion,
27 userDataPath,
28 ferdiLocale,
29} from '../environment-remote';
30import locales from '../i18n/translations'; 22import locales from '../i18n/translations';
31import { getLocale } from '../helpers/i18n-helpers'; 23import { getLocale } from '../helpers/i18n-helpers';
32 24
@@ -41,8 +33,6 @@ const debug = require('debug')('Ferdi:AppStore');
41 33
42const mainWindow = getCurrentWindow(); 34const mainWindow = getCurrentWindow();
43 35
44const defaultLocale = DEFAULT_APP_SETTINGS.locale;
45
46const executablePath = isMac ? remoteProcess.execPath : process.execPath; 36const executablePath = isMac ? remoteProcess.execPath : process.execPath;
47const autoLauncher = new AutoLaunch({ 37const autoLauncher = new AutoLaunch({
48 name: 'Ferdi', 38 name: 'Ferdi',
@@ -80,9 +70,9 @@ export default class AppStore extends Store {
80 70
81 @observable timeOfflineStart; 71 @observable timeOfflineStart;
82 72
83 @observable updateStatus = null; 73 @observable updateStatus = '';
84 74
85 @observable locale = defaultLocale; 75 @observable locale = ferdiLocale;
86 76
87 @observable isSystemMuteOverridden = false; 77 @observable isSystemMuteOverridden = false;
88 78
@@ -408,7 +398,7 @@ export default class AppStore extends Store {
408 } 398 }
409 399
410 @action _resetUpdateStatus() { 400 @action _resetUpdateStatus() {
411 this.updateStatus = null; 401 this.updateStatus = '';
412 } 402 }
413 403
414 @action _healthCheck() { 404 @action _healthCheck() {
@@ -480,23 +470,13 @@ export default class AppStore extends Store {
480 } 470 }
481 471
482 _setLocale() { 472 _setLocale() {
483 let locale; 473 if (this.stores.user.isLoggedIn && this.stores.user.data.locale) {
484 if (this.stores.user.isLoggedIn) { 474 this.locale = this.stores.user.data.locale;
485 locale = this.stores.user.data.locale; 475 } else if (!this.locale) {
486 }
487
488 if (
489 locale &&
490 Object.prototype.hasOwnProperty.call(locales, locale) &&
491 locale !== this.locale
492 ) {
493 this.locale = locale;
494 } else if (!locale) {
495 this.locale = this._getDefaultLocale(); 476 this.locale = this._getDefaultLocale();
496 } 477 }
497 478
498 moment.locale(this.locale); 479 moment.locale(this.locale);
499
500 debug(`Set locale to "${this.locale}"`); 480 debug(`Set locale to "${this.locale}"`);
501 } 481 }
502 482
@@ -504,7 +484,6 @@ export default class AppStore extends Store {
504 return getLocale({ 484 return getLocale({
505 locale: ferdiLocale, 485 locale: ferdiLocale,
506 locales, 486 locales,
507 defaultLocale,
508 fallbackLocale: DEFAULT_APP_SETTINGS.fallbackLocale, 487 fallbackLocale: DEFAULT_APP_SETTINGS.fallbackLocale,
509 }); 488 });
510 } 489 }
@@ -523,10 +502,12 @@ export default class AppStore extends Store {
523 _handleFullScreen() { 502 _handleFullScreen() {
524 const body = document.querySelector('body'); 503 const body = document.querySelector('body');
525 504
526 if (this.isFullScreen) { 505 if (body) {
527 body.classList.add('isFullScreen'); 506 if (this.isFullScreen) {
528 } else { 507 body.classList.add('isFullScreen');
529 body.classList.remove('isFullScreen'); 508 } else {
509 body.classList.remove('isFullScreen');
510 }
530 } 511 }
531 } 512 }
532 513