fix(tours): keep unknown actual tracks unknown and name every track a link replaces (ACT-01)

A tour detail that cannot be read (offline without a cached copy, or a server
error) no longer shows "No actual track yet" while the trip list names tracks
of the tour; the section says they could not be loaded and offers no link over
them.

The day a track was recorded on is the viewer's calendar day of its first time
stamp, not the UTC one, in the tour detail, the link dialog and the GPX
preview alike, through one helper.

Taking a tour off a day keeps its actual track without a day, so "no day" can
hold several. A change now starts on the track it was asked for, and the link
dialog names every track it replaces, as the server clears all of them. The
migration, repository, service and MCP texts say so.

The refusal for linking a tour to itself or a track with tracks of its own now
reads "This track cannot be linked to this tour", which is true of both, and
the offline helper of the tour cache sits above the doc of replaceTripTours
again.
This commit is contained in:
Maurice
2026-10-20 12:50:38 +02:00
parent d0cc6fc2f4
commit a8be1c5b45
46 changed files with 243 additions and 100 deletions
+6 -6
View File
@@ -464,12 +464,6 @@ export async function replaceTripRows<T extends { id: number }>(table: TripScope
});
}
/**
* {@link replaceTripRows} for the Tours facet, which is keyed on `place_id`.
* A tour's cached control points survive the refresh only while its route
* reads the same: the list carries no waypoints, and a route edited elsewhere
* must not open offline with the old ones.
*/
/** The recorded tracks a cached detail holds, while the list still names the same ones (ACT-01). */
function keptActivities(previous: CachedTour | undefined, tour: TourListItem): Pick<CachedTour, 'activities'> {
const refs = (item: Pick<TourListItem, 'activity_tracks'>) =>
@@ -477,6 +471,12 @@ function keptActivities(previous: CachedTour | undefined, tour: TourListItem): P
return previous?.activities && refs(previous) === refs(tour) ? { activities: previous.activities } : {}
}
/**
* {@link replaceTripRows} for the Tours facet, which is keyed on `place_id`.
* A tour's cached control points survive the refresh only while its route
* reads the same: the list carries no waypoints, and a route edited elsewhere
* must not open offline with the old ones.
*/
export async function replaceTripTours(tripId: number, tours: TourListItem[]): Promise<void> {
await offlineDb.transaction('rw', offlineDb.tours, async () => {
const cached = new Map((await offlineDb.tours.where('trip_id').equals(tripId).toArray()).map(t => [t.place_id, t]));