From 82ded809782556cefd5f946659798d514331928c Mon Sep 17 00:00:00 2001 From: Maurice Date: Sat, 28 Nov 2026 00:33:37 +0100 Subject: [PATCH] fix(mobile): read the stop being moved as it is now, so a change by a collaborator is not lost The move list keeps only the stop's id and looks up its current day on every tap, and closes once the stop is gone from the place. --- .../screens/trip/sheets/MPlaceSheet.tsx | 20 ++++++++++++------- .../unit/mobile/trip/MPlaceSheet.test.tsx | 20 ++++++++++++++++++- 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/client/src/mobile/screens/trip/sheets/MPlaceSheet.tsx b/client/src/mobile/screens/trip/sheets/MPlaceSheet.tsx index 1c6df3821..c58d9e074 100644 --- a/client/src/mobile/screens/trip/sheets/MPlaceSheet.tsx +++ b/client/src/mobile/screens/trip/sheets/MPlaceSheet.tsx @@ -62,7 +62,8 @@ export default function MPlaceSheet({ planner, shell }: MTripSheetsProps) { } = usePlaceFileUpload(place && !isTourPlace ? place.id : null, fd => planner.tripActions.addFile(planner.tripId, fd), planner.toast) const [dayPickerOpen, setDayPickerOpen] = useState(false) // A day of this place picked to move from (#2583): the day list then moves it there instead of adding it. - const [moving, setMoving] = useState<{ assignment: Assignment; fromDayId: number } | null>(null) + // Only the ids are kept, so a stop a collaborator moved or removed meanwhile is read as it is now. + const [movingIds, setMovingIds] = useState<{ placeId: number; assignmentId: number } | null>(null) const [participantPickerOpen, setParticipantPickerOpen] = useState(false) const [navOpen, setNavOpen] = useState(false) const navBtnRef = useRef(null) @@ -72,7 +73,7 @@ export default function MPlaceSheet({ planner, shell }: MTripSheetsProps) { planner.setSelectedPlaceId(null) setFilesExpanded(false) setDayPickerOpen(false) - setMoving(null) + setMovingIds(null) setParticipantPickerOpen(false) setColorPickerOpen(false) } @@ -94,13 +95,18 @@ export default function MPlaceSheet({ planner, shell }: MTripSheetsProps) { return rows }, [place, planner.days, planner.assignments]) + const moving = movingIds && movingIds.placeId === place?.id + ? placeAssignments.find(r => r.assignment.id === movingIds.assignmentId) ?? null + : null + if (movingIds && !moving) setMovingIds(null) + const unassignedDays = planner.days.filter(d => !placeAssignments.some(r => r.day.id === d.id)) const dayLabel = (d: Day) => d.title || t('planner.dayN', { n: (d.day_number ?? planner.days.indexOf(d) + 1) || '?' }) // Lands where its time belongs on the new day, as a move on the desktop does; // without a time it goes to the end. - const moveToDay = ({ assignment, fromDayId }: { assignment: Assignment; fromDayId: number }, toDayId: number) => { + const moveToDay = ({ assignment, day }: { assignment: Assignment; day: Day }, toDayId: number) => { const slot = timedSlot(planner.storedAssignments[String(toDayId)] || [], planner.tripAccommodations, assignment.place?.place_time) ?? undefined - planner.handleMoveToDay(assignment.id, fromDayId, toDayId, slot) + planner.handleMoveToDay(assignment.id, day.id, toDayId, slot) .catch((err: unknown) => planner.toast.error(err instanceof Error ? err.message : t('common.unknownError'))) } @@ -364,7 +370,7 @@ export default function MPlaceSheet({ planner, shell }: MTripSheetsProps) { // and notes, where removing and adding it again would lose them.