From ae6f7024ced56dd9535f11a1ff63bfbcac6963bf Mon Sep 17 00:00:00 2001 From: tophf Date: Thu, 10 Feb 2022 09:53:02 +0300 Subject: [PATCH] identify by UUID when importing --- manage/import-export.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/manage/import-export.js b/manage/import-export.js index 02b16599..343251db 100644 --- a/manage/import-export.js +++ b/manage/import-export.js @@ -104,6 +104,7 @@ async function importFromString(jsonString) { const json = tryJSONparse(jsonString); const oldStyles = Array.isArray(json) && json.length ? await API.styles.getAll() : []; const oldStylesById = new Map(oldStyles.map(style => [style.id, style])); + const oldStylesByUuid = new Map(oldStyles.map(style => [style._id, style])); const oldStylesByName = new Map(oldStyles.map(style => [style.name.trim(), style])); const oldOrder = await API.styles.getOrder(); const items = []; @@ -144,10 +145,11 @@ async function importFromString(jsonString) { } item.name = item.name.trim(); const byId = oldStylesById.get(item.id); + const byUuid = oldStylesByUuid.get(item._id); const byName = oldStylesByName.get(item.name); oldStylesByName.delete(item.name); - let oldStyle; - if (byId) { + let oldStyle = byUuid; + if (!oldStyle && byId) { if (sameStyle(byId, item)) { oldStyle = byId; } else {