aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfragosti <francesco.agosti93@gmail.com>2018-05-26 03:02:45 +0800
committerfragosti <francesco.agosti93@gmail.com>2018-05-26 03:03:18 +0800
commit9631927a8cbbc739f1e1d0d574c61e19803ee0dc (patch)
treef291e1882b9209a19540fb2652e8a686df725550
parentb0e6ce581a77d752d4a0b7f025237c4ac0aee010 (diff)
downloaddexon-sol-tools-9631927a8cbbc739f1e1d0d574c61e19803ee0dc.tar
dexon-sol-tools-9631927a8cbbc739f1e1d0d574c61e19803ee0dc.tar.gz
dexon-sol-tools-9631927a8cbbc739f1e1d0d574c61e19803ee0dc.tar.bz2
dexon-sol-tools-9631927a8cbbc739f1e1d0d574c61e19803ee0dc.tar.lz
dexon-sol-tools-9631927a8cbbc739f1e1d0d574c61e19803ee0dc.tar.xz
dexon-sol-tools-9631927a8cbbc739f1e1d0d574c61e19803ee0dc.tar.zst
dexon-sol-tools-9631927a8cbbc739f1e1d0d574c61e19803ee0dc.zip
Add localstorage helper
-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() };
+ },
+};