diff options
author | Stefan Malzner <stefan@adlk.io> | 2018-03-27 15:19:44 +0200 |
---|---|---|
committer | Stefan Malzner <stefan@adlk.io> | 2018-03-27 15:19:44 +0200 |
commit | 63d4281300ef86cbec6869bad3cbbb976c219c7d (patch) | |
tree | 29ae51983e0e7b07f0d450b6b8928a227620903a /src/stores/UserStore.js | |
parent | move windows arch config to electron-builder.yml (diff) | |
download | ferdium-app-63d4281300ef86cbec6869bad3cbbb976c219c7d.tar.gz ferdium-app-63d4281300ef86cbec6869bad3cbbb976c219c7d.tar.zst ferdium-app-63d4281300ef86cbec6869bad3cbbb976c219c7d.zip |
Move "locale" to user data
Diffstat (limited to 'src/stores/UserStore.js')
-rw-r--r-- | src/stores/UserStore.js | 20 |
1 files changed, 20 insertions, 0 deletions
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'; | |||
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; |
@@ -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 | } |