traccar / traccar-web

Traccar GPS Tracking System
https://www.traccar.org
Apache License 2.0
814 stars 1.12k forks source link

Update the itemsCoordinates state every time the length of itemsRoute… #1251

Closed jorgeart81 closed 3 months ago

jorgeart81 commented 3 months ago

Hello, I hope this PR is helpful to you.

Update the itemsCoordinates state every time the length of itemsRoutes changes.

Before -> the map was returning to its initial state when the state was updated with the socket

https://github.com/traccar/traccar-web/assets/92123185/2c3e0279-eb36-471f-8787-ea079ccfbde7

After

https://github.com/traccar/traccar-web/assets/92123185/9bc325df-fc87-4fee-8170-9286ccaf5102

tananaev commented 3 months ago

Why does it update everything on the socket update?

jorgeart81 commented 3 months ago

El socket actualiza el estado del store. Por ejemplo en devices en el caso del CombinedReportPage.jsx

It seems to me that PageLayout should be the parent of reports, so it will not be affected.

You can check the PR https://github.com/traccar/traccar-web/pull/1252

tananaev commented 3 months ago

Sounds like using useMemo would be the right approach here.