2025-01-08 16:25:41 +00:00
|
|
|
import { fromJS, isIndexed } from 'immutable';
|
2023-05-23 15:15:17 +00:00
|
|
|
|
2018-03-04 19:27:25 +00:00
|
|
|
import { hydrateCompose } from './compose';
|
2018-03-24 12:06:27 +00:00
|
|
|
import { importFetchedAccounts } from './importer';
|
2023-09-07 12:56:19 +00:00
|
|
|
import { hydrateSearch } from './search';
|
2017-01-09 11:37:15 +00:00
|
|
|
|
|
|
|
export const STORE_HYDRATE = 'STORE_HYDRATE';
|
2017-07-07 22:06:02 +00:00
|
|
|
export const STORE_HYDRATE_LAZY = 'STORE_HYDRATE_LAZY';
|
2017-01-09 11:37:15 +00:00
|
|
|
|
|
|
|
const convertState = rawState =>
|
2017-07-10 23:00:14 +00:00
|
|
|
fromJS(rawState, (k, v) =>
|
2025-01-08 16:25:41 +00:00
|
|
|
isIndexed(v) ? v.toList() : v.toMap());
|
2023-11-03 15:00:03 +00:00
|
|
|
|
2017-01-09 11:37:15 +00:00
|
|
|
export function hydrateStore(rawState) {
|
2018-03-04 19:27:25 +00:00
|
|
|
return dispatch => {
|
|
|
|
const state = convertState(rawState);
|
2017-01-09 11:37:15 +00:00
|
|
|
|
2018-03-04 19:27:25 +00:00
|
|
|
dispatch({
|
|
|
|
type: STORE_HYDRATE,
|
|
|
|
state,
|
|
|
|
});
|
|
|
|
|
|
|
|
dispatch(hydrateCompose());
|
2023-09-07 12:56:19 +00:00
|
|
|
dispatch(hydrateSearch());
|
2018-03-24 12:06:27 +00:00
|
|
|
dispatch(importFetchedAccounts(Object.values(rawState.accounts)));
|
2017-01-09 11:37:15 +00:00
|
|
|
};
|
2022-12-18 15:51:37 +00:00
|
|
|
}
|