From 63d4281300ef86cbec6869bad3cbbb976c219c7d Mon Sep 17 00:00:00 2001 From: Stefan Malzner Date: Tue, 27 Mar 2018 15:19:44 +0200 Subject: Move "locale" to user data --- src/stores/UserStore.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/stores/UserStore.js') 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'; import CachedRequest from './lib/CachedRequest'; import { gaEvent } from '../lib/analytics'; +const debug = require('debug')('UserStore'); + // TODO: split stores into UserStore and AuthStore export default class UserStore extends Store { BASE_ROUTE = '/auth'; @@ -69,6 +71,11 @@ export default class UserStore extends Store { ]); } + setup() { + // Data migration + this._migrateUserLocale(); + } + // Routes get loginRoute() { return this.LOGIN_ROUTE; @@ -292,4 +299,17 @@ export default class UserStore extends Store { this.id = null; } } + + async _migrateUserLocale() { + await this.getUserInfoRequest._promise; + + if (!this.data.locale) { + debug('Migrate "locale" to user data'); + this.actions.user.update({ + userData: { + locale: this.stores.app.locale, + }, + }); + } + } } -- cgit v1.2.3-54-g00ecf