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