fix(tours): offer the map comparison only where the plan map can draw it (ACT-02)

The compare switch in a tour's detail showed whenever the detail sat beside
the plan map, but the map draws no comparison in road trip mode or with the
trip overview open. Pressing it there turned the switch on while nothing
appeared on the map.

The plan map now tells the compare store whether it can draw a comparison.
The detail offers the switch only then, and turning to the road trip or the
overview, or leaving the map, ends a running comparison.
This commit is contained in:
Maurice
2026-10-20 13:09:56 +02:00
parent 6a0c54cb2f
commit ae79ab8dad
7 changed files with 75 additions and 13 deletions
@@ -15,12 +15,23 @@ interface ActivityComparison {
interface TourActivityCompareState {
comparison: ActivityComparison | null;
/**
* Whether the plan map can draw a comparison right now. The map says so
* itself: in road trip mode, with the trip overview open or on the phone it
* draws other lines, and the detail then offers no switch that would do
* nothing.
*/
mapAvailable: boolean;
show: (comparison: ActivityComparison | null) => void;
clear: () => void;
/** Set by the plan map; a map that can no longer compare ends the comparison too. */
setMapAvailable: (available: boolean) => void;
}
export const useTourActivityCompareStore = create<TourActivityCompareState>((set) => ({
comparison: null,
mapAvailable: false,
show: (comparison) => set({ comparison }),
clear: () => set({ comparison: null }),
setMapAvailable: (available) => set(available ? { mapAvailable: true } : { mapAvailable: false, comparison: null }),
}));