Skip to content

Commit

Permalink
fix: persisted available models ard not be update after source code h…
Browse files Browse the repository at this point in the history
…ave been updated
  • Loading branch information
skymkmk committed Sep 15, 2024
1 parent 027e5ad commit 9e1e0a7
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions app/store/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 9e1e0a7

Please sign in to comment.