Clear fetched plugin on clearSelectedCells
Fixes issue with selected cells persisting when navigating between different plugins.
This commit is contained in:
parent
f1afb2d258
commit
a7e4b2e657
@ -4,8 +4,8 @@ import Gradient from "javascript-color-gradient";
|
|||||||
import mapboxgl from "mapbox-gl";
|
import mapboxgl from "mapbox-gl";
|
||||||
import useSWRImmutable from "swr/immutable";
|
import useSWRImmutable from "swr/immutable";
|
||||||
|
|
||||||
import { useAppSelector } from "../lib/hooks";
|
import { useAppDispatch, useAppSelector } from "../lib/hooks";
|
||||||
import { PluginFile } from "../slices/plugins";
|
import { setFetchedPlugin, PluginFile } from "../slices/plugins";
|
||||||
import styles from "../styles/Map.module.css";
|
import styles from "../styles/Map.module.css";
|
||||||
import Sidebar from "./Sidebar";
|
import Sidebar from "./Sidebar";
|
||||||
import ToggleLayersControl from "./ToggleLayersControl";
|
import ToggleLayersControl from "./ToggleLayersControl";
|
||||||
@ -60,6 +60,7 @@ const Map: React.FC = () => {
|
|||||||
>(null);
|
>(null);
|
||||||
const [sidebarOpen, setSidebarOpen] = useState(true);
|
const [sidebarOpen, setSidebarOpen] = useState(true);
|
||||||
|
|
||||||
|
const dispatch = useAppDispatch();
|
||||||
const plugins = useAppSelector((state) => state.plugins.plugins);
|
const plugins = useAppSelector((state) => state.plugins.plugins);
|
||||||
const pluginsPending = useAppSelector((state) => state.plugins.pending);
|
const pluginsPending = useAppSelector((state) => state.plugins.pending);
|
||||||
const fetchedPlugin = useAppSelector((state) => state.plugins.fetchedPlugin);
|
const fetchedPlugin = useAppSelector((state) => state.plugins.fetchedPlugin);
|
||||||
@ -247,6 +248,7 @@ const Map: React.FC = () => {
|
|||||||
|
|
||||||
const clearSelectedCells = useCallback(() => {
|
const clearSelectedCells = useCallback(() => {
|
||||||
setSelectedCells(null);
|
setSelectedCells(null);
|
||||||
|
dispatch(setFetchedPlugin(undefined));
|
||||||
if (map.current) {
|
if (map.current) {
|
||||||
map.current.removeFeatureState({ source: "selected-cell-source" });
|
map.current.removeFeatureState({ source: "selected-cell-source" });
|
||||||
map.current.removeFeatureState({ source: "conflicted-cell-source" });
|
map.current.removeFeatureState({ source: "conflicted-cell-source" });
|
||||||
|
Loading…
Reference in New Issue
Block a user