diff --git a/frontend/package-lock.json b/frontend/package-lock.json index b42293f1..c6510e0b 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -8,7 +8,7 @@ "name": "frontend", "version": "0.0.0", "dependencies": { - "@reduxjs/toolkit": "^1.9.2", + "@reduxjs/toolkit": "^2.2.7", "@vercel/analytics": "^0.1.10", "chart.js": "^4.4.4", "i18next": "^23.14.0", @@ -1066,18 +1066,18 @@ } }, "node_modules/@reduxjs/toolkit": { - "version": "1.9.2", - "resolved": "https://registry.npmjs.org/@reduxjs/toolkit/-/toolkit-1.9.2.tgz", - "integrity": "sha512-5ZAZ7hwAKWSii5T6NTPmgIBUqyVdlDs+6JjThz6J6dmHLDm6zCzv2OjHIFAi3Vvs1qjmXU0bm6eBojukYXjVMQ==", + "version": "2.2.7", + "resolved": "https://registry.npmjs.org/@reduxjs/toolkit/-/toolkit-2.2.7.tgz", + "integrity": "sha512-faI3cZbSdFb8yv9dhDTmGwclW0vk0z5o1cia+kf7gCbaCwHI5e+7tP57mJUv22pNcNbeA62GSrPpfrUfdXcQ6g==", "dependencies": { - "immer": "^9.0.16", - "redux": "^4.2.0", - "redux-thunk": "^2.4.2", - "reselect": "^4.1.7" + "immer": "^10.0.3", + "redux": "^5.0.1", + "redux-thunk": "^3.1.0", + "reselect": "^5.1.0" }, "peerDependencies": { "react": "^16.9.0 || ^17.0.0 || ^18", - "react-redux": "^7.2.1 || ^8.0.2" + "react-redux": "^7.2.1 || ^8.1.3 || ^9.0.0" }, "peerDependenciesMeta": { "react": { @@ -1662,7 +1662,7 @@ "version": "18.3.0", "resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-18.3.0.tgz", "integrity": "sha512-EhwApuTmMBmXuFOikhQLIBUn6uFg81SwLMOAUgodJF14SOBOCMdU04gDoYi0WOJJHD144TL32z4yDqCW3dnkQg==", - "devOptional": true, + "dev": true, "dependencies": { "@types/react": "*" } @@ -4776,9 +4776,9 @@ } }, "node_modules/immer": { - "version": "9.0.19", - "resolved": "https://registry.npmjs.org/immer/-/immer-9.0.19.tgz", - "integrity": "sha512-eY+Y0qcsB4TZKwgQzLaE/lqYMlKhv5J9dyd2RhhtGhNo2njPXDqU9XPfcNfa3MIDsdtZt5KlkIsirlo4dHsWdQ==", + "version": "10.1.1", + "resolved": "https://registry.npmjs.org/immer/-/immer-10.1.1.tgz", + "integrity": "sha512-s2MPrmjovJcoMaHtx6K11Ra7oD05NT97w1IC5zpMkT6Atjr7H8LjaDd81iIxUYpMKSRRNMJE703M1Fhr/TctHw==", "funding": { "type": "opencollective", "url": "https://opencollective.com/immer" @@ -7594,9 +7594,9 @@ } }, "node_modules/react-redux": { - "version": "8.0.5", - "resolved": "https://registry.npmjs.org/react-redux/-/react-redux-8.0.5.tgz", - "integrity": "sha512-Q2f6fCKxPFpkXt1qNRZdEDLlScsDWyrgSj0mliK59qU6W5gvBiKkdMEG2lJzhd1rCctf0hb6EtePPLZ2e0m1uw==", + "version": "8.1.3", + "resolved": "https://registry.npmjs.org/react-redux/-/react-redux-8.1.3.tgz", + "integrity": "sha512-n0ZrutD7DaX/j9VscF+uTALI3oUPa/pO4Z3soOBIjuRn/FzVu6aehhysxZCLi6y7duMf52WNZGMl7CtuK5EnRw==", "dependencies": { "@babel/runtime": "^7.12.1", "@types/hoist-non-react-statics": "^3.3.1", @@ -7611,7 +7611,7 @@ "react": "^16.8 || ^17.0 || ^18.0", "react-dom": "^16.8 || ^17.0 || ^18.0", "react-native": ">=0.59", - "redux": "^4" + "redux": "^4 || ^5.0.0-beta.0" }, "peerDependenciesMeta": { "@types/react": { @@ -7712,19 +7712,16 @@ } }, "node_modules/redux": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/redux/-/redux-4.2.1.tgz", - "integrity": "sha512-LAUYz4lc+Do8/g7aeRa8JkyDErK6ekstQaqWQrNRW//MY1TvCEpMtpTWvlQ+FPbWCx+Xixu/6SHt5N0HR+SB4w==", - "dependencies": { - "@babel/runtime": "^7.9.2" - } + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/redux/-/redux-5.0.1.tgz", + "integrity": "sha512-M9/ELqF6fy8FwmkpnF0S3YKOqMyoWJ4+CS5Efg2ct3oY9daQvd/Pc71FpGZsVsbl3Cpb+IIcjBDUnnyBdQbq4w==" }, "node_modules/redux-thunk": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/redux-thunk/-/redux-thunk-2.4.2.tgz", - "integrity": "sha512-+P3TjtnP0k/FEjcBL5FZpoovtvrTNT/UXd4/sluaSyrURlSlhLSzEdfsTBW7WsKB6yPvgd7q/iZPICFjW4o57Q==", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/redux-thunk/-/redux-thunk-3.1.0.tgz", + "integrity": "sha512-NW2r5T6ksUKXCabzhL9z+h206HQw/NJkcLm1GPImRQ8IzfXwRGqjVhKJGauHirT0DAuyy6hjdnMZaRoAcy0Klw==", "peerDependencies": { - "redux": "^4" + "redux": "^5.0.0" } }, "node_modules/reflect.getprototypeof": { @@ -7877,9 +7874,9 @@ } }, "node_modules/reselect": { - "version": "4.1.7", - "resolved": "https://registry.npmjs.org/reselect/-/reselect-4.1.7.tgz", - "integrity": "sha512-Zu1xbUt3/OPwsXL46hvOOoQrap2azE7ZQbokq61BQfiXvhewsKDwhMeZjTX9sX0nvw1t/U5Audyn1I9P/m9z0A==" + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/reselect/-/reselect-5.1.1.tgz", + "integrity": "sha512-K/BG6eIky/SBpzfHZv/dd+9JBFiS4SWV7FIujVyJRux6e45+73RaUHXLmIR1f7WOMaQ0U1km6qwklRQxpJJY0w==" }, "node_modules/resolve": { "version": "1.22.8", diff --git a/frontend/package.json b/frontend/package.json index e781c5e4..cbed6245 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -19,7 +19,7 @@ ] }, "dependencies": { - "@reduxjs/toolkit": "^1.9.2", + "@reduxjs/toolkit": "^2.2.7", "@vercel/analytics": "^0.1.10", "chart.js": "^4.4.4", "i18next": "^23.14.0", diff --git a/frontend/src/preferences/preferenceSlice.ts b/frontend/src/preferences/preferenceSlice.ts index 90fc354d..6fb2480b 100644 --- a/frontend/src/preferences/preferenceSlice.ts +++ b/frontend/src/preferences/preferenceSlice.ts @@ -8,7 +8,7 @@ import { setLocalApiKey, setLocalRecentDocs } from './preferenceApi'; import { RootState } from '../store'; import { ActiveState, Doc } from '../models/misc'; -interface Preference { +export interface Preference { apiKey: string; prompt: { name: string; id: string; type: string }; chunks: string; diff --git a/frontend/src/store.ts b/frontend/src/store.ts index a085dad3..565ea8cc 100644 --- a/frontend/src/store.ts +++ b/frontend/src/store.ts @@ -2,6 +2,7 @@ import { configureStore } from '@reduxjs/toolkit'; import { conversationSlice } from './conversation/conversationSlice'; import { sharedConversationSlice } from './conversation/sharedConversationSlice'; import { + Preference, prefListenerMiddleware, prefSlice, } from './preferences/preferenceSlice'; @@ -12,31 +13,32 @@ const chunks = localStorage.getItem('DocsGPTChunks'); const token_limit = localStorage.getItem('DocsGPTTokenLimit'); const doc = localStorage.getItem('DocsGPTRecentDocs'); -const store = configureStore({ - preloadedState: { - preference: { - apiKey: key ?? '', - prompt: - prompt !== null - ? JSON.parse(prompt) - : { name: 'default', id: 'default', type: 'private' }, - chunks: JSON.parse(chunks ?? '2').toString(), - token_limit: token_limit ? parseInt(token_limit) : 2000, - selectedDocs: doc !== null ? JSON.parse(doc) : null, - conversations: null, - sourceDocs: [ - { - name: 'default', - date: '', - model: '1.0', - type: 'remote', - id: 'default', - retriever: 'clasic', - }, - ], - modalState: 'INACTIVE', - }, +const preloadedState: { preference: Preference } = { + preference: { + apiKey: key ?? '', + prompt: + prompt !== null + ? JSON.parse(prompt) + : { name: 'default', id: 'default', type: 'private' }, + chunks: JSON.parse(chunks ?? '2').toString(), + token_limit: token_limit ? parseInt(token_limit) : 2000, + selectedDocs: doc !== null ? JSON.parse(doc) : null, + conversations: null, + sourceDocs: [ + { + name: 'default', + date: '', + model: '1.0', + type: 'remote', + id: 'default', + retriever: 'clasic', + }, + ], + modalState: 'INACTIVE', }, +}; +const store = configureStore({ + preloadedState: preloadedState, reducer: { preference: prefSlice.reducer, conversation: conversationSlice.reducer,