diff --git a/app/soapbox/actions/store.js b/app/soapbox/actions/store.js new file mode 100644 index 000000000..d6921d7f1 --- /dev/null +++ b/app/soapbox/actions/store.js @@ -0,0 +1,7 @@ +export const INIT_STORE = 'INIT_STORE'; + +export function initStore() { + return { + type: INIT_STORE, + }; +} diff --git a/app/soapbox/containers/soapbox.js b/app/soapbox/containers/soapbox.js index 8a3a52f3e..041fced17 100644 --- a/app/soapbox/containers/soapbox.js +++ b/app/soapbox/containers/soapbox.js @@ -14,6 +14,7 @@ import { ScrollContext } from 'react-router-scroll-4'; import UI from '../features/ui'; // import Introduction from '../features/introduction'; import { fetchCustomEmojis } from '../actions/custom_emojis'; +import { initStore } from '../actions/store'; import { preload } from '../actions/preload'; import { IntlProvider } from 'react-intl'; import ErrorBoundary from '../components/error_boundary'; @@ -30,6 +31,7 @@ const validLocale = locale => Object.keys(messages).includes(locale); export const store = configureStore(); +store.dispatch(initStore()); store.dispatch(preload()); store.dispatch(fetchMe()); store.dispatch(fetchInstance()); diff --git a/app/soapbox/reducers/__tests__/auth-test.js b/app/soapbox/reducers/__tests__/auth-test.js index 4adce1eae..6ea1111dc 100644 --- a/app/soapbox/reducers/__tests__/auth-test.js +++ b/app/soapbox/reducers/__tests__/auth-test.js @@ -1,5 +1,6 @@ import reducer from '../auth'; import { Map as ImmutableMap, fromJS } from 'immutable'; +import { INIT_STORE } from 'soapbox/actions/store'; import { AUTH_APP_CREATED, AUTH_LOGGED_IN, @@ -18,7 +19,7 @@ describe('auth reducer', () => { })); }); - describe('@@INIT', () => { + describe('INIT_STORE', () => { it('sets `me` to the next available user if blank', () => { const state = fromJS({ me: null, @@ -28,7 +29,7 @@ describe('auth reducer', () => { }, }); - const action = { type: '@@INIT' }; + const action = { type: INIT_STORE }; const result = reducer(state, action); expect(result.get('me')).toEqual('1234'); }); diff --git a/app/soapbox/reducers/auth.js b/app/soapbox/reducers/auth.js index 22e0d166b..18d7d1219 100644 --- a/app/soapbox/reducers/auth.js +++ b/app/soapbox/reducers/auth.js @@ -1,3 +1,4 @@ +import { INIT_STORE } from '../actions/store'; import { AUTH_APP_CREATED, AUTH_LOGGED_IN, @@ -104,7 +105,7 @@ const initialize = state => { const reducer = (state, action) => { switch(action.type) { - case '@@INIT': + case INIT_STORE: return initialize(state); case AUTH_APP_CREATED: return state.set('app', fromJS(action.app));