aboutsummaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
Diffstat (limited to 'packages')
-rw-r--r--packages/website/ts/local_storage/state_storage.ts16
1 files changed, 16 insertions, 0 deletions
diff --git a/packages/website/ts/local_storage/state_storage.ts b/packages/website/ts/local_storage/state_storage.ts
new file mode 100644
index 000000000..517784b5b
--- /dev/null
+++ b/packages/website/ts/local_storage/state_storage.ts
@@ -0,0 +1,16 @@
+import { localStorage } from 'ts/local_storage/local_storage';
+import { INITIAL_STATE, State } from 'ts/redux/reducer';
+
+const STORAGE_NAME = 'persistedState';
+
+export const stateStorage = {
+ saveState(partialState: Partial<State>): void {
+ localStorage.setObject(STORAGE_NAME, partialState);
+ },
+ getPersistedState(): Partial<State> {
+ return localStorage.getObject(STORAGE_NAME);
+ },
+ getPersistedDefaultState(): State {
+ return { ...INITIAL_STATE, ...stateStorage.getPersistedState() };
+ },
+};