Update localStorage with Scope state also on initial router hook.

This commit is contained in:
Filip Barl
2018-08-13 17:56:16 +02:00
parent 57a7e55355
commit af99a95100

View File

@@ -167,11 +167,11 @@ export function getRouter(dispatch, initialState) {
page('/state/:state', (ctx) => {
const state = JSON.parse(decodeURL(ctx.params.state));
const dirtyOptions = detectOldOptions(state.topologyOptions);
if (dirtyOptions) {
dispatch(route(initialState));
} else {
dispatch(route(state));
}
const nextState = dirtyOptions ? initialState : state;
// back up state in storage and redirect
storageSet(STORAGE_STATE_KEY, encodeURL(stableStringify(state)));
dispatch(route(nextState));
});
return page;