From 523d75d1ba34eac722b76b3ab026cec817c72ceb Mon Sep 17 00:00:00 2001 From: Sujit Date: Fri, 3 Jan 2025 13:08:20 +0545 Subject: [PATCH 1/2] fix: multilple api calls add `allow: once` to a event listener so that it will remove the listener immediately after it invoked once --- .../IndividualProject/GcpEditor/index.tsx | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/frontend/src/components/IndividualProject/GcpEditor/index.tsx b/src/frontend/src/components/IndividualProject/GcpEditor/index.tsx index 682df212..21a152e0 100644 --- a/src/frontend/src/components/IndividualProject/GcpEditor/index.tsx +++ b/src/frontend/src/components/IndividualProject/GcpEditor/index.tsx @@ -32,12 +32,15 @@ const GcpEditor = ({ }; useEffect(() => { - document.addEventListener(CUSTOM_EVENT, data => { - startProcessing(data); - }); - return document.removeEventListener(CUSTOM_EVENT, data => { - startProcessing(data); - }); + document.addEventListener( + CUSTOM_EVENT, + data => { + startProcessing(data); + }, + // When we use the {once: true} option when adding an event listener, the listener will be invoked at most once and immediately removed as soon as the event is invoked. + { once: true }, + ); + // eslint-disable-next-line react-hooks/exhaustive-deps }, [CUSTOM_EVENT, dispatch]); From d2453b8b62b5ee7058c8bc1e6c8f4d44ce9b6b98 Mon Sep 17 00:00:00 2001 From: Sujit Date: Thu, 9 Jan 2025 19:16:33 +0545 Subject: [PATCH 2/2] feat: update gcp-editor version --- src/frontend/package.json | 2 +- src/frontend/src/views/IndividualProject/index.tsx | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/frontend/package.json b/src/frontend/package.json index 26db65d5..0b752e67 100644 --- a/src/frontend/package.json +++ b/src/frontend/package.json @@ -2,7 +2,7 @@ "dependencies": { "@cyntler/react-doc-viewer": "^1.17.0", "@geomatico/maplibre-cog-protocol": "^0.3.1", - "@hotosm/gcp-editor": "^0.0.6", + "@hotosm/gcp-editor": "^0.0.8", "@mapbox/mapbox-gl-draw": "^1.4.2", "@mapbox/mapbox-gl-draw-static-mode": "^1.0.1", "@radix-ui/react-popover": "^1.0.6", diff --git a/src/frontend/src/views/IndividualProject/index.tsx b/src/frontend/src/views/IndividualProject/index.tsx index cad86267..1dc5cdfd 100644 --- a/src/frontend/src/views/IndividualProject/index.tsx +++ b/src/frontend/src/views/IndividualProject/index.tsx @@ -145,10 +145,10 @@ const IndividualProject = () => { close ) : (