refactor: Make all reducers sync (#4125)

This commit is contained in:
Sorin Davidoi
2017-07-09 12:16:08 +02:00
committed by Eugen Rochko
parent f68fa930ea
commit 37c832cdf7
8 changed files with 18 additions and 90 deletions

View File

@ -23,7 +23,7 @@ import {
COMPOSE_EMOJI_INSERT,
} from '../actions/compose';
import { TIMELINE_DELETE } from '../actions/timelines';
import { STORE_HYDRATE_LAZY } from '../actions/store';
import { STORE_HYDRATE } from '../actions/store';
import Immutable from 'immutable';
import uuid from '../uuid';
@ -134,7 +134,7 @@ const privacyPreference = (a, b) => {
export default function compose(state = initialState, action) {
switch(action.type) {
case `${STORE_HYDRATE_LAZY}-compose`:
case STORE_HYDRATE:
return clearAll(state.merge(action.state.get('compose')));
case COMPOSE_MOUNT:
return state.set('mounted', true);

View File

@ -14,6 +14,10 @@ import status_lists from './status_lists';
import cards from './cards';
import reports from './reports';
import contexts from './contexts';
import compose from './compose';
import search from './search';
import media_attachments from './media_attachments';
import notifications from './notifications';
const reducers = {
timelines,
@ -31,13 +35,10 @@ const reducers = {
cards,
reports,
contexts,
compose,
search,
media_attachments,
notifications,
};
export function createReducer(asyncReducers) {
return combineReducers({
...reducers,
...asyncReducers,
});
}
export default combineReducers(reducers);

View File

@ -1,4 +1,4 @@
import { STORE_HYDRATE_LAZY } from '../actions/store';
import { STORE_HYDRATE } from '../actions/store';
import Immutable from 'immutable';
const initialState = Immutable.Map({
@ -7,7 +7,7 @@ const initialState = Immutable.Map({
export default function meta(state = initialState, action) {
switch(action.type) {
case `${STORE_HYDRATE_LAZY}-media_attachments`:
case STORE_HYDRATE:
return state.merge(action.state.get('media_attachments'));
default:
return state;