From 9e1e0a72521cc84ef74499195f3734850b9ccd13 Mon Sep 17 00:00:00 2001 From: skymkmk Date: Mon, 16 Sep 2024 02:06:17 +0800 Subject: [PATCH] fix: persisted available models ard not be update after source code have been updated --- app/store/config.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/app/store/config.ts b/app/store/config.ts index 9985b9e768c..679135ee712 100644 --- a/app/store/config.ts +++ b/app/store/config.ts @@ -143,6 +143,21 @@ export const useAppConfig = createPersistStore( { name: StoreKey.Config, version: 4, + + merge(persistedState, currentState) { + const state = persistedState as ChatConfig | undefined; + if (!state) return { ...currentState }; + const models = currentState.models.slice(); + state.models.forEach((pModel) => { + const idx = models.findIndex( + (v) => v.name === pModel.name && v.provider === pModel.provider, + ); + if (idx !== -1) models[idx] = pModel; + else models.push(pModel); + }); + return { ...currentState, ...state, models: models }; + }, + migrate(persistedState, version) { const state = persistedState as ChatConfig;