diff --git a/client/src/pages/journeyDetail/useJourneyDetailRecordings.test.ts b/client/src/pages/journeyDetail/useJourneyDetailRecordings.test.ts index 74771f9a1..f9a9bde78 100644 --- a/client/src/pages/journeyDetail/useJourneyDetailRecordings.test.ts +++ b/client/src/pages/journeyDetail/useJourneyDetailRecordings.test.ts @@ -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']); + }); }); diff --git a/client/src/pages/journeyDetail/useJourneyDetailRecordings.ts b/client/src/pages/journeyDetail/useJourneyDetailRecordings.ts index daddedb40..9b90a9e0d 100644 --- a/client/src/pages/journeyDetail/useJourneyDetailRecordings.ts +++ b/client/src/pages/journeyDetail/useJourneyDetailRecordings.ts @@ -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,