mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-27 23:27:31 +00:00
fix(tours): keep a lost stage end visible on paddle tours
A stage end set on a lock or portage point the water router placed left the point automatic, so the router could drop it with its leg later, silently and without an undo step. Ending a stage there now makes the point the paddler's own, like any other edit of it. The notice for stage ends a change could not keep also vanished as soon as the router laid its points in again after the change. It now stays until the next change the user makes, an undo or redo, a save, or another draft.
This commit is contained in:
@@ -28,6 +28,7 @@ export interface PaddlePoint {
|
||||
fixedLeg?: TourFixedLeg | null;
|
||||
lock?: PaddleLock | null;
|
||||
shaping?: boolean;
|
||||
stageEnd?: boolean;
|
||||
/** Set by the planner where the router found a portage or a lock; gone once the paddler touches the point. */
|
||||
auto?: AutoBase;
|
||||
}
|
||||
@@ -224,7 +225,11 @@ export function materializePaddleLegs<T extends PaddlePoint>(
|
||||
return result;
|
||||
}
|
||||
|
||||
/** A point the paddler changed is theirs from then on: it loses its automatic mark. */
|
||||
/**
|
||||
* A point the paddler changed is theirs from then on: it loses its automatic
|
||||
* mark. Ending a stage there counts as a change (MDT-01), so the router never
|
||||
* drops a stage end with the leg around it.
|
||||
*/
|
||||
export function adoptChangedPoints<T extends PaddlePoint>(before: readonly T[], after: readonly T[]): T[] {
|
||||
const previous = new Map(before.map((point) => [point.id, point]));
|
||||
return after.map((point) => {
|
||||
@@ -233,6 +238,7 @@ export function adoptChangedPoints<T extends PaddlePoint>(before: readonly T[],
|
||||
const same =
|
||||
!!was &&
|
||||
samePlace(was, point) &&
|
||||
!!was.stageEnd === !!point.stageEnd &&
|
||||
JSON.stringify(was.lock ?? null) === JSON.stringify(point.lock ?? null) &&
|
||||
JSON.stringify(was.fixedLeg ?? null) === JSON.stringify(point.fixedLeg ?? null);
|
||||
if (same) return point;
|
||||
|
||||
Reference in New Issue
Block a user