import SwiftUI import ProxyCore import GRDB struct PinView: View { @State private var pinnedRequests: [CapturedTraffic] = [] @State private var observation: AnyDatabaseCancellable? private let trafficRepo = TrafficRepository() var body: some View { Group { if pinnedRequests.isEmpty { EmptyStateView( icon: "pin.slash", title: "No Pinned Requests", subtitle: "Pin requests from the Home tab to save them here for quick access." ) } else { List { ForEach(pinnedRequests) { request in NavigationLink(value: request.id) { TrafficRowView(traffic: request) } } } .navigationDestination(for: Int64?.self) { id in if let id { RequestDetailView(trafficId: id) } } } } .navigationTitle("Pin") .task { observation = trafficRepo.observePinnedTraffic() .start(in: DatabaseManager.shared.dbPool) { error in print("Pin observation error: \(error)") } onChange: { pinned in withAnimation { pinnedRequests = pinned } } } } }