about summary refs log tree commit diff
path: root/app/javascript/mastodon/store
diff options
context:
space:
mode:
authorSorin Davidoi <sorin.davidoi@gmail.com>2017-07-09 12:16:08 +0200
committerEugen Rochko <eugen@zeonfederated.com>2017-07-09 12:16:08 +0200
commit37c832cdf7a307511b27e64174ed1a3e160ec66e (patch)
treed06be7f23f6634286ffd7adf4fcddd3cbd6c3384 /app/javascript/mastodon/store
parentf68fa930ea448f5e94057160cfdcc78fec4aba11 (diff)
refactor: Make all reducers sync (#4125)
Diffstat (limited to 'app/javascript/mastodon/store')
-rw-r--r--app/javascript/mastodon/store/configureStore.js25
1 files changed, 2 insertions, 23 deletions
diff --git a/app/javascript/mastodon/store/configureStore.js b/app/javascript/mastodon/store/configureStore.js
index 0fe29f031..1376d4cba 100644
--- a/app/javascript/mastodon/store/configureStore.js
+++ b/app/javascript/mastodon/store/configureStore.js
@@ -1,36 +1,15 @@
 import { createStore, applyMiddleware, compose } from 'redux';
 import thunk from 'redux-thunk';
-import appReducer, { createReducer } from '../reducers';
-import { hydrateStoreLazy } from '../actions/store';
-import { hydrateAction } from '../containers/mastodon';
+import appReducer from '../reducers';
 import loadingBarMiddleware from '../middleware/loading_bar';
 import errorsMiddleware from '../middleware/errors';
 import soundsMiddleware from '../middleware/sounds';
 
 export default function configureStore() {
-  const store = createStore(appReducer, compose(applyMiddleware(
+  return createStore(appReducer, compose(applyMiddleware(
     thunk,
     loadingBarMiddleware({ promiseTypeSuffixes: ['REQUEST', 'SUCCESS', 'FAIL'] }),
     errorsMiddleware(),
     soundsMiddleware()
   ), window.devToolsExtension ? window.devToolsExtension() : f => f));
-
-  store.asyncReducers = { };
-
-  return store;
 };
-
-export function injectAsyncReducer(store, name, asyncReducer) {
-  if (!store.asyncReducers[name]) {
-    // Keep track that we injected this reducer
-    store.asyncReducers[name] = asyncReducer;
-
-    // Add the current reducer to the store
-    store.replaceReducer(createReducer(store.asyncReducers));
-
-    // The state this reducer handles defaults to its initial state (stored inside the reducer)
-    // But that state may be out of date because of the server-side hydration, so we replay
-    // the hydration action but only for this reducer (all async reducers must listen for this dynamic action)
-    store.dispatch(hydrateStoreLazy(name, hydrateAction.state));
-  }
-}