From ef98531ca28fe6a2f66d981b0d94aeecf380aef7 Mon Sep 17 00:00:00 2001 From: Tony Bark <35226681+tonytins@users.noreply.github.com> Date: Mon, 24 Aug 2026 23:25:34 -0400 Subject: [PATCH] Wired up isDataStale() If both isStale() and isDataStale() are in an agreement, no train is added to the list. --- Sources/AmtrakStatus/ContentView.swift | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Sources/AmtrakStatus/ContentView.swift b/Sources/AmtrakStatus/ContentView.swift index 2a48ffb..1366751 100644 --- a/Sources/AmtrakStatus/ContentView.swift +++ b/Sources/AmtrakStatus/ContentView.swift @@ -138,6 +138,7 @@ struct ContentView: View { } var zoneCache: [String: TimeZone?] = [code: lookup.timeZone] + let staleness = await staleTrainLookup() var newRows: [TrainStatusRow] = [] for number in lookup.trainNumbers { @@ -151,7 +152,8 @@ struct ContentView: View { for: train, code: code, zone: lookup.timeZone, - cache: &zoneCache + cache: &zoneCache, + staleness: staleness ) if let row { newRows.append(row) @@ -174,11 +176,15 @@ struct ContentView: View { for train: Train, code stationCode: String, zone timeZone: TimeZone?, - cache zoneCache: inout [String: TimeZone?] + cache zoneCache: inout [String: TimeZone?], + staleness: [String: TimeInterval] ) async -> TrainStatusRow? { let leg = train.stations?.first { $0.code == stationCode } - guard !isStale(leg, timeZone: timeZone) else { + guard + !isStale(leg, timeZone: timeZone) && + !isDataStale(train.trainID, staleness: staleness) + else { return nil }