From a4d012828c55b308e2ea0c57a250d0ac3709d02c Mon Sep 17 00:00:00 2001 From: imldy Date: Tue, 11 Jul 2023 21:02:09 +0800 Subject: [PATCH] fix: migrated mask object key --- app/store/mask.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/store/mask.ts b/app/store/mask.ts index 105ca346..02132b77 100644 --- a/app/store/mask.ts +++ b/app/store/mask.ts @@ -109,7 +109,7 @@ export const useMaskStore = create()( }), { 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()( Object.values(newState.masks).forEach((m) => (m.id = nanoid())); } + if (version < 3.1) { + const updatedMasks: Record = {}; + Object.values(newState.masks).forEach((m) => { + updatedMasks[m.id] = m; + }); + newState.masks = updatedMasks; + } + return newState as any; }, },