Skip to content

VSN-1976/ Changing logic of state to handle Auto-refrech after personalisation

ilyas makhloul a demandé de fusionner feature/vsn-1976 vers develop

Replace boolean refresh mechanism with reliable timestamp-based trigger

This merge request replaces the previous boolean-based refresh system (refreshSlots) with a more reliable timestamp trigger (refreshTrigger). The old mechanism was causing synchronization issues where the parent component did not always detect updates triggered from the child form, resulting in inconsistent data refresh after saving a trip.

What has been changed

Removed refreshSlots and setRefreshSlots props.

Added a new timestamp-based trigger: refreshTrigger and setRefreshTrigger.

Updated the parent component (DriverSchedule) to refresh data whenever the trigger value changes.

Updated TrajetPlanningForm to call setRefreshTrigger(Date.now()) after a successful save.

Simplified the parent useEffect by removing boolean reset logic, eliminating race conditions.

Improved synchronization between form actions and schedule data reloading.

Why this change

The boolean refresh flag could be reset too early during async operations, causing missed updates and inconsistent schedule reloading. Using a timestamp ensures each trigger is unique and guarantees the parent always reacts correctly.

Result

Reliable and deterministic data refresh

No more race conditions

Better separation of concerns between parent and child

Improved stability in planning updates

Rapports de requête de fusion