mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2025-08-21 04:28:13 -04:00
feat(gui): Preserve global state across page reloads (#48)
This commit is contained in:
parent
c7c7cf1886
commit
d913206062
5 changed files with 35 additions and 11 deletions
|
@ -1,9 +1,28 @@
|
|||
import { configureStore } from "@reduxjs/toolkit";
|
||||
import { combineReducers, configureStore } from "@reduxjs/toolkit";
|
||||
import { persistReducer, persistStore } from "redux-persist";
|
||||
import sessionStorage from "redux-persist/lib/storage/session";
|
||||
import { reducers } from "store/combinedReducer";
|
||||
|
||||
// We persist the redux store in sessionStorage
|
||||
// The point of this is to preserve the store across reloads while not persisting it across GUI restarts
|
||||
//
|
||||
// If the user reloads the page, while a swap is running we want to
|
||||
// continue displaying the correct state of the swap
|
||||
const persistConfig = {
|
||||
key: "gui-global-state-store",
|
||||
storage: sessionStorage,
|
||||
};
|
||||
|
||||
const persistedReducer = persistReducer(
|
||||
persistConfig,
|
||||
combineReducers(reducers),
|
||||
);
|
||||
|
||||
export const store = configureStore({
|
||||
reducer: reducers,
|
||||
reducer: persistedReducer,
|
||||
});
|
||||
|
||||
export const persistor = persistStore(store);
|
||||
|
||||
export type AppDispatch = typeof store.dispatch;
|
||||
export type RootState = ReturnType<typeof store.getState>;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue