logo

mastofe

My custom branche(s) on git.pleroma.social/pleroma/mastofe git clone https://hacktivis.me/git/mastofe.git

store.js (644B)


  1. import { Iterable, fromJS } from 'immutable';
  2. import { hydrateCompose } from './compose';
  3. import { importFetchedAccounts } from './importer';
  4. export const STORE_HYDRATE = 'STORE_HYDRATE';
  5. export const STORE_HYDRATE_LAZY = 'STORE_HYDRATE_LAZY';
  6. const convertState = rawState =>
  7. fromJS(rawState, (k, v) =>
  8. Iterable.isIndexed(v) ? v.toList() : v.toMap());
  9. export function hydrateStore(rawState) {
  10. return dispatch => {
  11. const state = convertState(rawState);
  12. dispatch({
  13. type: STORE_HYDRATE,
  14. state,
  15. });
  16. dispatch(hydrateCompose());
  17. dispatch(importFetchedAccounts(Object.values(rawState.accounts)));
  18. };
  19. };