From bf12e7e32cef427edacbd512d067c2bfd35d3b67 Mon Sep 17 00:00:00 2001 From: Harrison Healey Date: Fri, 23 Jun 2017 17:08:25 -0400 Subject: Load current user after loading client config (#6648) --- webapp/actions/user_actions.jsx | 75 +++++++++++++++++------------------------ 1 file changed, 31 insertions(+), 44 deletions(-) (limited to 'webapp/actions') diff --git a/webapp/actions/user_actions.jsx b/webapp/actions/user_actions.jsx index a1b0183bc..015c933bf 100644 --- a/webapp/actions/user_actions.jsx +++ b/webapp/actions/user_actions.jsx @@ -33,55 +33,42 @@ import {savePreferences, deletePreferences} from 'mattermost-redux/actions/prefe import {Preferences as PreferencesRedux} from 'mattermost-redux/constants'; -export function loadMe(callback) { - UserActions.loadMe()(dispatch, getState).then( - () => { - if (window.mm_config) { - loadCurrentLocale(); - } - - if (callback) { - callback(); - } +export function loadMe() { + return UserActions.loadMe()(dispatch, getState).then(() => { + if (window.mm_config) { + loadCurrentLocale(); } - ); + }); } export function loadMeAndConfig(callback) { - loadMe(() => { - getClientConfig()(store.dispatch, store.getState).then( - (config) => { - global.window.mm_config = config; - - if (global.window && global.window.analytics) { - global.window.analytics.identify(global.window.mm_config.DiagnosticId, {}, { - context: { - ip: '0.0.0.0' - }, - page: { - path: '', - referrer: '', - search: '', - title: '', - url: '' - }, - anonymousId: '00000000000000000000000000' - }); - } - - loadCurrentLocale(); - - getLicenseConfig()(store.dispatch, store.getState).then( - (license) => { // eslint-disable-line max-nested-callbacks - global.window.mm_license = license; + getClientConfig()(store.dispatch, store.getState).then((config) => { + global.window.mm_config = config; + + if (global.window && global.window.analytics) { + global.window.analytics.identify(global.window.mm_config.DiagnosticId, {}, { + context: { + ip: '0.0.0.0' + }, + page: { + path: '', + referrer: '', + search: '', + title: '', + url: '' + }, + anonymousId: '00000000000000000000000000' + }); + } - if (callback) { - callback(); - } - } - ); - } - ); + Promise.all([ + loadMe(), + getLicenseConfig()(store.dispatch, store.getState).then( + (license) => { + global.window.mm_license = license; + } + ) + ]).then(callback); }); } -- cgit v1.2.3-1-g7c22