aboutsummaryrefslogtreecommitdiffstats
path: root/src/stores
diff options
context:
space:
mode:
Diffstat (limited to 'src/stores')
-rw-r--r--src/stores/AppStore.js6
-rw-r--r--src/stores/UserStore.js20
2 files changed, 25 insertions, 1 deletions
diff --git a/src/stores/AppStore.js b/src/stores/AppStore.js
index 4ac8325d4..94ed308f3 100644
--- a/src/stores/AppStore.js
+++ b/src/stores/AppStore.js
@@ -15,6 +15,8 @@ import { gaEvent } from '../lib/analytics';
15 15
16import { getServiceIdsFromPartitions, removeServicePartitionDirectory } from '../helpers/service-helpers.js'; 16import { getServiceIdsFromPartitions, removeServicePartitionDirectory } from '../helpers/service-helpers.js';
17 17
18const debug = require('debug')('AppStore');
19
18const { app } = remote; 20const { app } = remote;
19 21
20const defaultLocale = DEFAULT_APP_SETTINGS.locale; 22const defaultLocale = DEFAULT_APP_SETTINGS.locale;
@@ -279,13 +281,15 @@ export default class AppStore extends Store {
279 } 281 }
280 282
281 _setLocale() { 283 _setLocale() {
282 const locale = this.stores.settings.all.locale; 284 const { locale } = this.stores.user.data;
283 285
284 if (locale && Object.prototype.hasOwnProperty.call(locales, locale) && locale !== this.locale) { 286 if (locale && Object.prototype.hasOwnProperty.call(locales, locale) && locale !== this.locale) {
285 this.locale = locale; 287 this.locale = locale;
286 } else if (!locale) { 288 } else if (!locale) {
287 this.locale = this._getDefaultLocale(); 289 this.locale = this._getDefaultLocale();
288 } 290 }
291
292 debug(`Set locale to "${this.locale}"`);
289 } 293 }
290 294
291 _getDefaultLocale() { 295 _getDefaultLocale() {
diff --git a/src/stores/UserStore.js b/src/stores/UserStore.js
index 7dbbd955b..c151f6d59 100644
--- a/src/stores/UserStore.js
+++ b/src/stores/UserStore.js
@@ -9,6 +9,8 @@ import Request from './lib/Request';
9import CachedRequest from './lib/CachedRequest'; 9import CachedRequest from './lib/CachedRequest';
10import { gaEvent } from '../lib/analytics'; 10import { gaEvent } from '../lib/analytics';
11 11
12const debug = require('debug')('UserStore');
13
12// TODO: split stores into UserStore and AuthStore 14// TODO: split stores into UserStore and AuthStore
13export default class UserStore extends Store { 15export default class UserStore extends Store {
14 BASE_ROUTE = '/auth'; 16 BASE_ROUTE = '/auth';
@@ -69,6 +71,11 @@ export default class UserStore extends Store {
69 ]); 71 ]);
70 } 72 }
71 73
74 setup() {
75 // Data migration
76 this._migrateUserLocale();
77 }
78
72 // Routes 79 // Routes
73 get loginRoute() { 80 get loginRoute() {
74 return this.LOGIN_ROUTE; 81 return this.LOGIN_ROUTE;
@@ -292,4 +299,17 @@ export default class UserStore extends Store {
292 this.id = null; 299 this.id = null;
293 } 300 }
294 } 301 }
302
303 async _migrateUserLocale() {
304 await this.getUserInfoRequest._promise;
305
306 if (!this.data.locale) {
307 debug('Migrate "locale" to user data');
308 this.actions.user.update({
309 userData: {
310 locale: this.stores.app.locale,
311 },
312 });
313 }
314 }
295} 315}