From 2e68d147b687bf58ebdd9e45133fb3e7a64436c1 Mon Sep 17 00:00:00 2001 From: cha0s Date: Sun, 20 Mar 2022 02:22:12 -0500 Subject: [PATCH] feat: hydrate --- package.json | 2 +- packages/core/src/state/resource.js | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 3c17fdf..a791181 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "@flecks/governor": "1.4.1", "@flecks/react": "^1.4.1", "@flecks/redis": "1.4.1", - "@flecks/redux": "1.4.1", + "@flecks/redux": "^1.4.1", "@flecks/repl": "1.4.1", "@flecks/server": "1.4.1", "@flecks/socket": "1.4.1", diff --git a/packages/core/src/state/resource.js b/packages/core/src/state/resource.js index 60e5d68..8a08bad 100644 --- a/packages/core/src/state/resource.js +++ b/packages/core/src/state/resource.js @@ -1,6 +1,7 @@ import { createSelector, createSlice, + hydrateLocalStorage, } from '@flecks/redux'; export const resourceSelector = (state) => state.resource; @@ -41,6 +42,12 @@ const slice = createSlice({ } }, }, + extraReducers: (builder) => { + builder.addCase(hydrateLocalStorage, (state, {payload}) => { + state.current = currentResourceSelector(payload); + state.open = openResourcesSelector(payload); + }); + }, /* eslint-enable no-param-reassign */ });