From 48b6522cf56640f284a80b9efc81a5d6ba5a85d1 Mon Sep 17 00:00:00 2001 From: Yusuf Suleman Date: Sat, 4 Apr 2026 14:32:56 -0500 Subject: [PATCH] debug: trips navigation lifecycle logging --- .../Features/Trips/ViewModels/TripsViewModel.swift | 10 ++++++++-- .../Features/Trips/Views/PastTripsSection.swift | 1 + .../Platform/Features/Trips/Views/TripsHomeView.swift | 6 ++++++ .../Features/Trips/Views/UpcomingTripsPageView.swift | 3 +++ 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/ios/Platform/Platform/Features/Trips/ViewModels/TripsViewModel.swift b/ios/Platform/Platform/Features/Trips/ViewModels/TripsViewModel.swift index 8192006..392ec63 100644 --- a/ios/Platform/Platform/Features/Trips/ViewModels/TripsViewModel.swift +++ b/ios/Platform/Platform/Features/Trips/ViewModels/TripsViewModel.swift @@ -27,8 +27,11 @@ final class TripsViewModel { error = nil do { - trips = try await api.getTrips() + let fetched = try await api.getTrips() + print("[TRIPS] loadTrips: fetched \(fetched.count) trips") + trips = fetched } catch { + print("[TRIPS] loadTrips ERROR: \(error)") self.error = error.localizedDescription } isLoading = false @@ -37,8 +40,11 @@ final class TripsViewModel { func refresh() async { isLoading = true do { - trips = try await api.getTrips() + let fetched = try await api.getTrips() + print("[TRIPS] refresh: fetched \(fetched.count) trips") + trips = fetched } catch { + print("[TRIPS] refresh ERROR: \(error)") self.error = error.localizedDescription } isLoading = false diff --git a/ios/Platform/Platform/Features/Trips/Views/PastTripsSection.swift b/ios/Platform/Platform/Features/Trips/Views/PastTripsSection.swift index d6c7dc7..7c91850 100644 --- a/ios/Platform/Platform/Features/Trips/Views/PastTripsSection.swift +++ b/ios/Platform/Platform/Features/Trips/Views/PastTripsSection.swift @@ -7,6 +7,7 @@ struct PastTripsSection: View { let namespace: Namespace.ID var body: some View { + let _ = { print("[TRIPS] PastTripsSection body — trips=\(trips.count) ids=\(trips.map(\.id))") }() if !trips.isEmpty { Section { ScrollView(.horizontal) { diff --git a/ios/Platform/Platform/Features/Trips/Views/TripsHomeView.swift b/ios/Platform/Platform/Features/Trips/Views/TripsHomeView.swift index 5684443..8336ce4 100644 --- a/ios/Platform/Platform/Features/Trips/Views/TripsHomeView.swift +++ b/ios/Platform/Platform/Features/Trips/Views/TripsHomeView.swift @@ -37,6 +37,12 @@ struct TripsHomeView: View { } } .background(Color.canvas) + .onAppear { + print("[TRIPS] TripsHomeView onAppear — trips=\(vm.trips.count) upcoming=\(vm.upcomingTrips.count) past=\(vm.pastTrips.count) isLoading=\(vm.isLoading)") + } + .onChange(of: vm.trips.count) { old, new in + print("[TRIPS] trips count changed \(old) → \(new)") + } .toolbar { // Custom expanded title — Wishlist pattern ToolbarItem(placement: .title) { diff --git a/ios/Platform/Platform/Features/Trips/Views/UpcomingTripsPageView.swift b/ios/Platform/Platform/Features/Trips/Views/UpcomingTripsPageView.swift index a89748b..43b8ae0 100644 --- a/ios/Platform/Platform/Features/Trips/Views/UpcomingTripsPageView.swift +++ b/ios/Platform/Platform/Features/Trips/Views/UpcomingTripsPageView.swift @@ -8,6 +8,7 @@ struct UpcomingTripsPageView: View { @Namespace private var namespace var body: some View { + let _ = { print("[TRIPS] UpcomingTripsPageView body — trips=\(trips.count) ids=\(trips.map(\.id))") }() if trips.isEmpty { // No upcoming trips — show a prompt VStack(spacing: 16) { @@ -30,6 +31,8 @@ struct UpcomingTripsPageView: View { TripPlaceholderView(trip: trip) .navigationTransition( .zoom(sourceID: trip.id, in: namespace)) + .onAppear { print("[TRIPS] detail onAppear: \(trip.name)") } + .onDisappear { print("[TRIPS] detail onDisappear: \(trip.name)") } } label: { TripImageView(url: trip.imageURL, fallbackName: trip.name) .overlay(alignment: .bottomLeading) {