Use our own INIT_STORE action instead of relying on Redux's internal actions

bundle-emoji
Alex Gleason 2021-03-25 22:37:10 -05:00
rodzic ad3362e3cd
commit c7c0c41ce6
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 7211D1F99744FBB7
4 zmienionych plików z 14 dodań i 3 usunięć

Wyświetl plik

@ -0,0 +1,7 @@
export const INIT_STORE = 'INIT_STORE';
export function initStore() {
return {
type: INIT_STORE,
};
}

Wyświetl plik

@ -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());

Wyświetl plik

@ -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');
});

Wyświetl plik

@ -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));