mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-06 18:54:17 +00:00
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:
@@ -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 }),
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user