fix(journey): draw the live Dawarich trail in the colour of its day

The live trail arrived in Dawarich's own day palette, counted from the first
recorded day, while a journey colours its days by the entries. A day's line and
its pins therefore wore different colours. The trail of a day that has entries
now takes that day's colour, the way the kept recordings already did.

Closes #2906
This commit is contained in:
Maurice
2026-10-30 21:15:37 +01:00
parent 8eebcea9f5
commit 94a9cbf070
2 changed files with 22 additions and 4 deletions
@@ -1,4 +1,4 @@
// FE-JRN-DETAIL-RECORDINGS-001 to FE-JRN-DETAIL-RECORDINGS-003
// FE-JRN-DETAIL-RECORDINGS-001 to FE-JRN-DETAIL-RECORDINGS-004
//
// JRN-01: the journey page's map lines, with the days the journey keeps beside
// the trips' GPX tracks and the live Dawarich trail.
@@ -81,4 +81,15 @@ describe('useJourneyDetailRecordings', () => {
});
expect(setup({ dawarichStatus: 'disconnected' }).result.current.canTakeOverRecording).toBe(false);
});
it('FE-JRN-DETAIL-RECORDINGS-004: the live trail of a day with entries wears the colour of that day, a day without keeps its own (#2906)', async () => {
repo.list.mockResolvedValue([]);
const live = [
line({ place_id: -1, trip_id: 0, kind: 'dawarich_live', date: '2026-05-14', color: '#2563EB' }),
line({ place_id: -2, trip_id: 0, kind: 'dawarich_live', date: '2026-05-15', color: '#7C3AED' }),
];
const { result } = setup({ liveTracks: live });
await waitFor(() => expect(repo.list).toHaveBeenCalledWith(7));
expect(result.current.mapTracks.map((track) => track.color)).toEqual(['#aa0000', '#ff0055', '#7C3AED']);
});
});
@@ -6,7 +6,7 @@ import type { DawarichSuggestionsStatus } from '../../hooks/useDawarichSuggestio
/**
* The recorded days a journey keeps (JRN-01) as the journey page wires them:
* their lines in the colour of the pins of their day, beside the trips' GPX
* tracks and the live Dawarich trail. A kept day is the journey's own, so it
* tracks and the live Dawarich trail, which takes those colours too. A kept day is the journey's own, so it
* draws whatever the GPX switch says, and wins over the live trail of its date.
*/
export function useJourneyDetailRecordings({
@@ -42,9 +42,16 @@ export function useJourneyDetailRecordings({
const mapTracks = useMemo(() => {
if (recordings.tracks.length === 0 && liveTracks.length === 0) return tripTracks;
const live = liveTracks.filter((track) => !track.date || !recordings.byDate.has(track.date));
// The live trail comes in Dawarich's own day palette; on a journey a day wears
// the colour of its entries, so the line of a day with entries takes theirs (#2906).
const live = liveTracks
.filter((track) => !track.date || !recordings.byDate.has(track.date))
.map((track) => {
const color = track.date ? colorOfDay(track.date) : null;
return color && color !== track.color ? { ...track, color } : track;
});
return [...tripTracks, ...recordings.tracks, ...live];
}, [tripTracks, recordings.tracks, recordings.byDate, liveTracks]);
}, [tripTracks, recordings.tracks, recordings.byDate, liveTracks, colorOfDay]);
return {
recordings,