adds middleware to sync redux with local storage also adds ununsed

import error rule to linter
This commit is contained in:
ajaythapliyal
2023-02-24 18:46:46 +05:30
parent d98b558ab0
commit b662c30508
8 changed files with 81 additions and 5922 deletions

View File

@@ -1,13 +1,31 @@
import { configureStore } from '@reduxjs/toolkit';
import { conversationSlice } from './conversation/conversationSlice';
import { prefSlice } from './preferences/preferenceSlice';
import {
prefListenerMiddleware,
prefSlice,
} from './preferences/preferenceSlice';
const key = localStorage.getItem('DocsGPTApiKey');
const doc = localStorage.getItem('DocsGPTRecentDocs');
const store = configureStore({
preloadedState: {
preference: {
apiKey: key ?? '',
selectedDocs: doc !== null ? JSON.parse(doc) : null,
sourceDocs: null,
},
},
reducer: {
preference: prefSlice.reducer,
conversation: conversationSlice.reducer,
},
middleware: (getDefaultMiddleware) => [
...getDefaultMiddleware(),
prefListenerMiddleware.middleware,
],
});
export type RootState = ReturnType<typeof store.getState>;
export type AppDispatch = typeof store.dispatch;
export default store;