diff --git a/app/soapbox/containers/soapbox.js b/app/soapbox/containers/soapbox.js index 63fe783de..352031bc6 100644 --- a/app/soapbox/containers/soapbox.js +++ b/app/soapbox/containers/soapbox.js @@ -33,9 +33,14 @@ const validLocale = locale => Object.keys(messages).includes(locale); export const store = configureStore(); store.dispatch(preload()); -store.dispatch(fetchMe()); -store.dispatch(fetchInstance()); -store.dispatch(fetchSoapboxConfig()); + +store.dispatch(fetchMe()) + .then(() => { + // Postpone for authenticated fetch + store.dispatch(fetchInstance()); + store.dispatch(fetchSoapboxConfig()); + }) + .catch(() => {}); const mapStateToProps = (state) => { const me = state.get('me'); diff --git a/app/soapbox/features/auth_login/components/login_page.js b/app/soapbox/features/auth_login/components/login_page.js index 8cdb07ee0..720616616 100644 --- a/app/soapbox/features/auth_login/components/login_page.js +++ b/app/soapbox/features/auth_login/components/login_page.js @@ -6,6 +6,7 @@ import { injectIntl } from 'react-intl'; import LoginForm from './login_form'; import OtpAuthForm from './otp_auth_form'; import { logIn, verifyCredentials, switchAccount } from 'soapbox/actions/auth'; +import { fetchInstance } from 'soapbox/actions/instance'; import { isStandalone } from 'soapbox/utils/state'; const mapStateToProps = state => ({ @@ -40,7 +41,9 @@ class LoginPage extends ImmutablePureComponent { const { dispatch, intl, me } = this.props; const { username, password } = this.getFormData(event.target); dispatch(logIn(intl, username, password)).then(({ access_token }) => { - return dispatch(verifyCredentials(access_token)); + return dispatch(verifyCredentials(access_token)) + // Refetch the instance for authenticated fetch + .then(() => dispatch(fetchInstance())); }).then(account => { this.setState({ shouldRedirect: true }); if (typeof me === 'string') { diff --git a/app/soapbox/features/public_layout/components/header.js b/app/soapbox/features/public_layout/components/header.js index d537fe4db..3c87739e6 100644 --- a/app/soapbox/features/public_layout/components/header.js +++ b/app/soapbox/features/public_layout/components/header.js @@ -9,6 +9,7 @@ import SoapboxPropTypes from 'soapbox/utils/soapbox_prop_types'; import { defineMessages, injectIntl } from 'react-intl'; import PropTypes from 'prop-types'; import { logIn, verifyCredentials } from 'soapbox/actions/auth'; +import { fetchInstance } from 'soapbox/actions/instance'; import OtpAuthForm from 'soapbox/features/auth_login/components/otp_auth_form'; import IconButton from 'soapbox/components/icon_button'; @@ -55,7 +56,9 @@ class Header extends ImmutablePureComponent { const { dispatch, intl } = this.props; const { username, password } = this.getFormData(event.target); dispatch(logIn(intl, username, password)).then(({ access_token }) => { - return dispatch(verifyCredentials(access_token)); + return dispatch(verifyCredentials(access_token)) + // Refetch the instance for authenticated fetch + .then(() => dispatch(fetchInstance())); }).catch(error => { if (error.response.data.error === 'mfa_required') { this.setState({ mfa_auth_needed: true, mfa_token: error.response.data.mfa_token });