Skip to content

Commit

Permalink
Merge pull request #2360 from imldy/fix_can't_edit_old_mask
Browse files Browse the repository at this point in the history
fix: 迁移面具对象的key以解决无法编辑旧面具的问题
  • Loading branch information
Yidadaa authored Jul 11, 2023
2 parents c44454b + a4d0128 commit c7c318b
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion app/store/mask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
},
},
Expand Down

0 comments on commit c7c318b

Please sign in to comment.