forked from XiaoMo/ChatGPT-Next-Web
Merge pull request #2360 from imldy/fix_can't_edit_old_mask
fix: 迁移面具对象的key以解决无法编辑旧面具的问题
This commit is contained in:
commit
c7c318b31e
@ -109,7 +109,7 @@ export const useMaskStore = create<MaskStore>()(
|
||||
}),
|
||||
{
|
||||
name: StoreKey.Mask,
|
||||
version: 3,
|
||||
version: 3.1,
|
||||
|
||||
migrate(state, version) {
|
||||
const newState = JSON.parse(JSON.stringify(state)) as MaskState;
|
||||
@ -119,6 +119,14 @@ export const useMaskStore = create<MaskStore>()(
|
||||
Object.values(newState.masks).forEach((m) => (m.id = nanoid()));
|
||||
}
|
||||
|
||||
if (version < 3.1) {
|
||||
const updatedMasks: Record<string, Mask> = {};
|
||||
Object.values(newState.masks).forEach((m) => {
|
||||
updatedMasks[m.id] = m;
|
||||
});
|
||||
newState.masks = updatedMasks;
|
||||
}
|
||||
|
||||
return newState as any;
|
||||
},
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user