mirror of https://github.com/arc53/DocsGPT
adds middleware to sync redux with local storage also adds ununsed
import error rule to linterpull/122/head
parent
d98b558ab0
commit
b662c30508
File diff suppressed because it is too large
Load Diff
@ -1,13 +1,31 @@
|
|||||||
import { configureStore } from '@reduxjs/toolkit';
|
import { configureStore } from '@reduxjs/toolkit';
|
||||||
import { conversationSlice } from './conversation/conversationSlice';
|
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({
|
const store = configureStore({
|
||||||
|
preloadedState: {
|
||||||
|
preference: {
|
||||||
|
apiKey: key ?? '',
|
||||||
|
selectedDocs: doc !== null ? JSON.parse(doc) : null,
|
||||||
|
sourceDocs: null,
|
||||||
|
},
|
||||||
|
},
|
||||||
reducer: {
|
reducer: {
|
||||||
preference: prefSlice.reducer,
|
preference: prefSlice.reducer,
|
||||||
conversation: conversationSlice.reducer,
|
conversation: conversationSlice.reducer,
|
||||||
},
|
},
|
||||||
|
middleware: (getDefaultMiddleware) => [
|
||||||
|
...getDefaultMiddleware(),
|
||||||
|
prefListenerMiddleware.middleware,
|
||||||
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export type RootState = ReturnType<typeof store.getState>;
|
||||||
export type AppDispatch = typeof store.dispatch;
|
export type AppDispatch = typeof store.dispatch;
|
||||||
export default store;
|
export default store;
|
||||||
|
Loading…
Reference in New Issue