diff options
Diffstat (limited to 'src/stores/UserStore.js')
-rw-r--r-- | src/stores/UserStore.js | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/src/stores/UserStore.js b/src/stores/UserStore.js index 7dbbd955b..574616925 100644 --- a/src/stores/UserStore.js +++ b/src/stores/UserStore.js | |||
@@ -9,6 +9,8 @@ import Request from './lib/Request'; | |||
9 | import CachedRequest from './lib/CachedRequest'; | 9 | import CachedRequest from './lib/CachedRequest'; |
10 | import { gaEvent } from '../lib/analytics'; | 10 | import { gaEvent } from '../lib/analytics'; |
11 | 11 | ||
12 | const debug = require('debug')('UserStore'); | ||
13 | |||
12 | // TODO: split stores into UserStore and AuthStore | 14 | // TODO: split stores into UserStore and AuthStore |
13 | export default class UserStore extends Store { | 15 | export 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; |
@@ -256,8 +263,10 @@ export default class UserStore extends Store { | |||
256 | 263 | ||
257 | // We need to set the beta flag for the SettingsStore | 264 | // We need to set the beta flag for the SettingsStore |
258 | this.actions.settings.update({ | 265 | this.actions.settings.update({ |
259 | settings: { | 266 | type: 'app', |
267 | data: { | ||
260 | beta: data.beta, | 268 | beta: data.beta, |
269 | locale: data.locale, | ||
261 | }, | 270 | }, |
262 | }); | 271 | }); |
263 | } | 272 | } |
@@ -292,4 +301,17 @@ export default class UserStore extends Store { | |||
292 | this.id = null; | 301 | this.id = null; |
293 | } | 302 | } |
294 | } | 303 | } |
304 | |||
305 | async _migrateUserLocale() { | ||
306 | await this.getUserInfoRequest._promise; | ||
307 | |||
308 | if (!this.data.locale) { | ||
309 | debug('Migrate "locale" to user data'); | ||
310 | this.actions.user.update({ | ||
311 | userData: { | ||
312 | locale: this.stores.app.locale, | ||
313 | }, | ||
314 | }); | ||
315 | } | ||
316 | } | ||
295 | } | 317 | } |