From e21271f78ba088fa2a391b905172b6b96a9f60ff Mon Sep 17 00:00:00 2001 From: Tyler Hallada Date: Sat, 12 Mar 2022 21:29:40 -0500 Subject: [PATCH] Fix updating map as plugins are selected --- components/Map.tsx | 9 +-------- components/PluginDetail.tsx | 3 +-- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/components/Map.tsx b/components/Map.tsx index 364fa30..5fe0e5c 100644 --- a/components/Map.tsx +++ b/components/Map.tsx @@ -248,10 +248,6 @@ const Map: React.FC = () => { const clearSelectedCells = useCallback(() => { setSelectedCells(null); - if (router.query.plugin !== fetchedPlugin?.hash.toString(36)) { - console.log("clearing fetched plugin"); - dispatch(setFetchedPlugin(undefined)); - } if (map.current) { map.current.removeFeatureState({ source: "selected-cell-source" }); map.current.removeFeatureState({ source: "conflicted-cell-source" }); @@ -259,7 +255,7 @@ const Map: React.FC = () => { requestAnimationFrame(() => { if (map.current) map.current.resize(); }); - }, [map, fetchedPlugin, dispatch, router.query.plugin]); + }, [map]); const clearSelectedMod = useCallback(() => { requestAnimationFrame(() => { @@ -303,8 +299,6 @@ const Map: React.FC = () => { clearSelectedCell(); } } else if (router.query.plugin && typeof router.query.plugin === "string") { - clearSelectedCell(); - clearSelectedCells(); setSidebarOpen(true); if (plugins && plugins.length > 0 && pluginsPending === 0) { const plugin = plugins.find((p) => p.hash === router.query.plugin); @@ -369,7 +363,6 @@ const Map: React.FC = () => { useEffect(() => { if (router.query.plugin && typeof router.query.plugin === "string" && fetchedPlugin && fetchedPlugin.cells) { - console.log("selecting fetchedPlugin cells"); const cells = []; const cellSet = new Set(); for (const cell of fetchedPlugin.cells) { diff --git a/components/PluginDetail.tsx b/components/PluginDetail.tsx index 3a5d066..4a82454 100644 --- a/components/PluginDetail.tsx +++ b/components/PluginDetail.tsx @@ -50,8 +50,7 @@ const PluginDetail: React.FC = ({ hash, counts }) => { const plugin = plugins.find((plugin) => plugin.hash === hash); useEffect(() => { - if (data && !fetchedPlugin) { - console.log("setting fetched plugins from PluginDetail", data); + if (data) { dispatch(setFetchedPlugin(data)); } }, [dispatch, data, fetchedPlugin])