kopia lustrzana https://gitlab.com/soapbox-pub/soapbox
Use our own INIT_STORE action instead of relying on Redux's internal actions
rodzic
ad3362e3cd
commit
c7c0c41ce6
|
@ -0,0 +1,7 @@
|
|||
export const INIT_STORE = 'INIT_STORE';
|
||||
|
||||
export function initStore() {
|
||||
return {
|
||||
type: INIT_STORE,
|
||||
};
|
||||
}
|
|
@ -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());
|
||||
|
|
|
@ -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');
|
||||
});
|
||||
|
|
|
@ -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));
|
||||
|
|
Ładowanie…
Reference in New Issue