Skip to content

Commit 241e939

Browse files
committed
fix: 첫 렌더링 시 pages 쿼리 중복 요청 수정
1 parent 2163953 commit 241e939

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

frontend/src/components/canvas/index.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,23 @@ function Flow({ className }: CanvasProps) {
7474
const initialNodes = Array.from(nodesMap.values()) as Node[];
7575
setNodes(initialNodes);
7676

77+
let isInitialSync = true;
78+
7779
nodesMap.observe((event) => {
80+
if (isInitialSync) {
81+
isInitialSync = false;
82+
return;
83+
}
84+
7885
event.changes.keys.forEach((change, key) => {
7986
const nodeId = key;
8087
if (change.action === "add" || change.action === "update") {
8188
const updatedNode = nodesMap.get(nodeId) as Node;
8289

8390
if (change.action === "add") {
84-
queryClient.invalidateQueries({ queryKey: ["pages"] });
91+
if (!existingPageIds.current.has(nodeId)) {
92+
queryClient.invalidateQueries({ queryKey: ["pages"] });
93+
}
8594
}
8695

8796
setNodes((nds) => {

0 commit comments

Comments
 (0)