From 1d7758b8191907a1758bddfc94ec9776a4a55330 Mon Sep 17 00:00:00 2001 From: Maurice Date: Thu, 15 Oct 2026 21:40:19 +0000 Subject: [PATCH] Tours: the trip copy keeps its copied tours in one map, so trips.service stays at its size baseline; unused TourMapVisibility type removed --- client/src/components/Tours/useTourMapVisibility.ts | 2 -- server/src/nest/trips/trips.service.ts | 9 +++------ 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/client/src/components/Tours/useTourMapVisibility.ts b/client/src/components/Tours/useTourMapVisibility.ts index 30e40a439..de8f2a2be 100644 --- a/client/src/components/Tours/useTourMapVisibility.ts +++ b/client/src/components/Tours/useTourMapVisibility.ts @@ -36,5 +36,3 @@ export function useTourMapVisibility(tripId: number, tourIds: ReadonlySet; diff --git a/server/src/nest/trips/trips.service.ts b/server/src/nest/trips/trips.service.ts index 94d03dc46..d4c0a59ab 100644 --- a/server/src/nest/trips/trips.service.ts +++ b/server/src/nest/trips/trips.service.ts @@ -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(); - const copiedSources: Array<[number, number]> = []; + const copiedTours = new Map(); 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(); for (const { place_id, ...waypoint } of await this.tourWaypointsRepo.listForTrip(Number(sourceTripId))) {