修复lint errors
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import React, { useEffect, useMemo, useState } from "react";
|
||||
import React, { useEffect, useMemo, useRef, useState } from "react";
|
||||
import {
|
||||
Box,
|
||||
Typography,
|
||||
@@ -115,7 +115,7 @@ const EmptyState = () => (
|
||||
|
||||
const LocationResults: React.FC<Props> = ({ result }) => {
|
||||
const map = useMap();
|
||||
const [highlightLayer, setHighlightLayer] = useState<VectorLayer<VectorSource> | null>(null);
|
||||
const highlightLayerRef = useRef<VectorLayer<VectorSource> | null>(null);
|
||||
const [highlightFeatures, setHighlightFeatures] = useState<Feature[]>([]);
|
||||
|
||||
const candidatePipes = useMemo<BurstCandidate[]>(() => {
|
||||
@@ -128,13 +128,13 @@ const LocationResults: React.FC<Props> = ({ result }) => {
|
||||
return base;
|
||||
}, [result]);
|
||||
|
||||
const allCandidatePipeIds = useMemo<string[]>(() => {
|
||||
const allCandidatePipeIds = (() => {
|
||||
const ids = candidatePipes.map((item) => item.pipe_id);
|
||||
if (result?.located_pipe) {
|
||||
ids.unshift(result.located_pipe);
|
||||
}
|
||||
return Array.from(new Set(ids.filter(Boolean)));
|
||||
}, [candidatePipes, result?.located_pipe]);
|
||||
})();
|
||||
|
||||
useEffect(() => {
|
||||
if (!map) return;
|
||||
@@ -159,19 +159,20 @@ const LocationResults: React.FC<Props> = ({ result }) => {
|
||||
},
|
||||
});
|
||||
map.addLayer(layer);
|
||||
setHighlightLayer(layer);
|
||||
highlightLayerRef.current = layer;
|
||||
|
||||
return () => {
|
||||
highlightLayerRef.current = null;
|
||||
map.removeLayer(layer);
|
||||
};
|
||||
}, [map]);
|
||||
|
||||
useEffect(() => {
|
||||
const source = highlightLayer?.getSource();
|
||||
const source = highlightLayerRef.current?.getSource();
|
||||
if (!source) return;
|
||||
source.clear();
|
||||
highlightFeatures.forEach((feature) => source.addFeature(feature));
|
||||
}, [highlightFeatures, highlightLayer]);
|
||||
}, [highlightFeatures]);
|
||||
|
||||
const locatePipes = async (pipeIds: string[]) => {
|
||||
if (!pipeIds.length || !map) return;
|
||||
|
||||
Reference in New Issue
Block a user