Tours: the trip copy keeps its copied tours in one map, so trips.service stays at its size baseline; unused TourMapVisibility type removed

This commit is contained in:
Maurice
2026-10-15 21:40:19 +00:00
parent b33727ec75
commit 1d7758b819
2 changed files with 3 additions and 8 deletions
@@ -36,5 +36,3 @@ export function useTourMapVisibility(tripId: number, tourIds: ReadonlySet<number
return { hiddenIds, isHidden, toggle, showAll, hiddenCount: hiddenIds.size };
}
export type TourMapVisibility = ReturnType<typeof useTourMapVisibility>;
+3 -6
View File
@@ -737,17 +737,14 @@ export class TripsService {
// through; without them the copy is a plain place with a line, no Tour, its route not editable.
// The facet row goes first, since the waypoints and the import record reference it.
const oldTours = await this.toursRepo.listRowsForTrip(Number(sourceTripId));
const copiedTours = new Set<number>();
const copiedSources: Array<[number, number]> = [];
const copiedTours = new Map<number, number>();
for (const { place_id, ...tour } of oldTours) {
const newPlaceId = placeMap.get(place_id);
if (!newPlaceId) continue;
await this.toursRepo.insertCopy(newPlaceId, tour, placeMap);
copiedSources.push([place_id, newPlaceId]);
copiedTours.add(place_id);
copiedTours.set(place_id, newPlaceId);
}
// The import records after the facets they reference; the order among them does not matter.
await Promise.all(copiedSources.map(([from, to]) => this.toursRepo.copySource(from, to)));
await Promise.all([...copiedTours].map(([from, to]) => this.toursRepo.copySource(from, to)));
const waypointsByPlace = new Map<number, TourWaypointRow[]>();
for (const { place_id, ...waypoint } of await this.tourWaypointsRepo.listForTrip(Number(sourceTripId))) {