Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 7d477849

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

reidxing + drag jump fix

re #9741

Zobrazit rozdíly:

frontend/src/features/TrackingTool/DraggableList/DraggableMarkerList.tsx
1 1
import { Paper } from '@mui/material'
2
import { useEffect, useState } from 'react'
2
import { useEffect, useState, useCallback } from 'react'
3 3
import { DropResult } from 'react-beautiful-dnd'
4 4
import { useDispatch, useSelector } from 'react-redux'
5 5
import { RootState } from '../../redux/store'
6
import { swapMapMarkerIndices } from '../trackingToolSlice'
6
import { moveMarkerToDestination } from '../trackingToolSlice'
7 7
import { PathVariant } from '../Map/pathUtils'
8 8
import DraggableList from './DraggableList'
9 9

  
......
33 33
        setPath(paths[primaryPathIdx])
34 34
    }, [paths, primaryPathIdx])
35 35

  
36
    const onDragEnd = ({ destination, source }: DropResult) => {
36
    const onDragEnd = useCallback(({ destination, source }: DropResult) => {
37 37
        if (!destination || !source || destination.index === source.index) {
38 38
            return
39 39
        }
40 40

  
41 41
        dispatch(
42
            swapMapMarkerIndices({
42
            moveMarkerToDestination({
43 43
                source: source.index,
44 44
                destination: destination.index,
45 45
            })
46 46
        )
47
    }
47
    }, [dispatch])
48 48

  
49 49
    return (
50 50
        <Paper variant="outlined">

Také k dispozici: Unified diff