Projekt

Obecné

Profil

« Předchozí | Další » 

Revize dd270a41

Přidáno uživatelem Václav Honzík před více než 2 roky(ů)

path autorefresh works as intended

re #9629

Zobrazit rozdíly:

frontend/src/features/TrackingTool/MapPath.tsx
3 3
import { PathVariant } from './buildPathVariants'
4 4
import TextPath from 'react-leaflet-textpath'
5 5
import { Marker, Popup } from 'react-leaflet'
6
import { Checkbox, FormControlLabel, Stack, Typography } from '@mui/material'
6
import {
7
    Checkbox,
8
    FormControlLabel,
9
    Paper,
10
    Stack,
11
    Typography,
12
} from '@mui/material'
7 13
import { formatHtmlStringToReactDom } from '../../utils/formatting/HtmlUtils'
8 14
import { DialogCatalogItemDetail as CatalogItemDetailDialog } from '../Catalog/CatalogItemDetail'
9 15
import { useDispatch, useSelector } from 'react-redux'
......
31 37
// Map path component
32 38
const MapPath: FunctionComponent<MapPathProps> = ({ idx, pathVariant }) => {
33 39
    // List of all map points that belong to the path
34
    const [mapPoints, setMapPoints] = useState<DisplayableMapPoint[]>(
35
        pathVariant
36
            .filter((item) => item.latitude && item.longitude)
37
            .map((item) => new DisplayableMapPoint(item))
40
    const pathVariants = useSelector(
41
        (state: RootState) => state.trackingTool.pathVariants
38 42
    )
43
    const [mapPoints, setMapPoints] = useState<DisplayableMapPoint[]>([])
44
    const dispatch = useDispatch()
39 45

  
40 46
    // Set of all active paths
41 47
    const activePaths = useSelector(
......
54 60

  
55 61
    const getActiveMapPoints = () => mapPoints.filter((item) => item.active)
56 62

  
57
    const dispatch = useDispatch()
63
    // Refresh the list of map points if it has changed
64
    useEffect(() => {
65
        if (!pathVariants || pathVariants.length <= idx) {
66
            return
67
        }
68
        setMapPoints(
69
            [...pathVariants[idx]]
70
                .filter((item) => item.latitude && item.longitude)
71
                .map((item) => new DisplayableMapPoint(item))
72
        )
73
    }, [pathVariants, idx])
58 74

  
59 75
    // Builds all edges of the path
60 76
    const buildEdges = () => {

Také k dispozici: Unified diff