From 045a9b2f39c50e565873447ace9ea8eba195a53e Mon Sep 17 00:00:00 2001 From: Daseul Kim Date: Wed, 23 Oct 2024 17:17:43 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20canvas=20plan=20=EB=B3=80=EA=B2=BD?= =?UTF-8?q?=20=EC=97=AC=EB=B6=80=20=ED=99=95=EC=9D=B8=EC=9D=84=20id->uuid?= =?UTF-8?q?=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hooks/usePlan.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/hooks/usePlan.js b/src/hooks/usePlan.js index 87d43021..26d26339 100644 --- a/src/hooks/usePlan.js +++ b/src/hooks/usePlan.js @@ -62,6 +62,7 @@ export function usePlan() { 'stickeyPoint', 'text', 'pitch', + 'uuid', ]) const str = JSON.stringify(objs) @@ -108,16 +109,16 @@ export function usePlan() { return JSON.parse(canvasStatus).objects.length > 0 } else { // 저장된 캔버스 - // 각각 object들의 id 목록을 추출하여 비교 - const canvasObjsIds = getObjectIds(JSON.parse(canvasStatus).objects) - const dbObjsIds = getObjectIds(JSON.parse(initPlanData.canvasStatus).objects) - return canvasObjsIds.length !== dbObjsIds.length || !canvasObjsIds.every((id, index) => id === dbObjsIds[index]) + // 각각 object들의 uuid 목록을 추출하여 비교 + const canvasObjsUuids = getObjectUuids(JSON.parse(canvasStatus).objects) + const dbObjsUuids = getObjectUuids(JSON.parse(initPlanData.canvasStatus).objects) + return canvasObjsUuids.length !== dbObjsUuids.length || !canvasObjsUuids.every((id, index) => id === dbObjsUuids[index]) } } - const getObjectIds = (objects) => { + const getObjectUuids = (objects) => { return objects - .filter((obj) => obj.hasOwnProperty('id')) - .map((obj) => obj.id) + .filter((obj) => obj.hasOwnProperty('uuid')) + .map((obj) => obj.uuid) .sort() } /**