Compare commits
3
Commits
90fb3b7385
...
d73a64023f
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d73a64023f | ||
|
|
dc6d1fd724 | ||
|
|
10e3b54d0c |
@@ -56,14 +56,16 @@ struct ContentView: View {
|
|||||||
|
|
||||||
/// Kicks off a (throttled) Apple-Maps road-distance recompute for the
|
/// Kicks off a (throttled) Apple-Maps road-distance recompute for the
|
||||||
/// stations around the current fix. The app owns routing — the widget and
|
/// stations around the current fix. The app owns routing — the widget and
|
||||||
/// Live Activity only read the cached result.
|
/// Live Activity only read the cached result. Falls back to the last saved
|
||||||
|
/// location so it can run before the first fresh GPS fix arrives.
|
||||||
private func refreshRoadDistancesIfNeeded() {
|
private func refreshRoadDistancesIfNeeded() {
|
||||||
guard let location else { return }
|
let origin = location ?? FuelStore.loadLocation()
|
||||||
|
guard let origin else { return }
|
||||||
Task {
|
Task {
|
||||||
await RoadDistanceService.refreshIfNeeded(
|
await RoadDistanceService.refreshIfNeeded(
|
||||||
stations: stations,
|
stations: stations,
|
||||||
lat: location.lat,
|
lat: origin.lat,
|
||||||
lng: location.lng
|
lng: origin.lng
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -332,6 +334,10 @@ struct ContentView: View {
|
|||||||
fuel: alertsFuel, radiusKM: effectiveAlertsRadiusKM)
|
fuel: alertsFuel, radiusKM: effectiveAlertsRadiusKM)
|
||||||
monitor.setEnabled(alertsEnabled)
|
monitor.setEnabled(alertsEnabled)
|
||||||
updateLiveActivity()
|
updateLiveActivity()
|
||||||
|
// Compute road distances early (throttled; falls back to the
|
||||||
|
// last saved location) so distance surfaces are road-matched
|
||||||
|
// as soon as stations are available.
|
||||||
|
refreshRoadDistancesIfNeeded()
|
||||||
// Refresh only when the cache is stale (twice-a-day policy).
|
// Refresh only when the cache is stale (twice-a-day policy).
|
||||||
// Skipped under the force-* hooks so the banner stays up.
|
// Skipped under the force-* hooks so the banner stays up.
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
@@ -377,6 +383,7 @@ struct ContentView: View {
|
|||||||
monitor.update(stations: stations, favourites: refreshedFavourites,
|
monitor.update(stations: stations, favourites: refreshedFavourites,
|
||||||
fuel: alertsFuel, radiusKM: effectiveAlertsRadiusKM)
|
fuel: alertsFuel, radiusKM: effectiveAlertsRadiusKM)
|
||||||
updateLiveActivity()
|
updateLiveActivity()
|
||||||
|
refreshRoadDistancesIfNeeded()
|
||||||
// No network fetch on foreground — pull-to-refresh is the override.
|
// No network fetch on foreground — pull-to-refresh is the override.
|
||||||
} else {
|
} else {
|
||||||
locationManager.stopForegroundTracking()
|
locationManager.stopForegroundTracking()
|
||||||
|
|||||||
@@ -934,15 +934,19 @@ struct FuelStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// MARK: Onboarding — the app shows the intro screen on first launch only
|
// MARK: Onboarding — the app shows the intro screen on first launch only
|
||||||
// (a test button in the Alerts tab re-opens it). Stored in the app group
|
// (a test button in the Alerts tab re-opens it). Stored KEYCHAIN-FIRST
|
||||||
// so the widget can see it too if ever needed.
|
// (with an app-group mirror) for the same reason as favourites/distance
|
||||||
|
// unit: free SideStore accounts don't provision the app-group container,
|
||||||
|
// so an app-group-only flag silently fails to save AND reloads as false,
|
||||||
|
// making onboarding re-appear on every launch. Keychain survives reinstall
|
||||||
|
// and is shared with the extension.
|
||||||
|
|
||||||
static func loadHasCompletedOnboarding() -> Bool {
|
static func loadHasCompletedOnboarding() -> Bool {
|
||||||
UserDefaults(suiteName: appGroupSuite)?.bool(forKey: onboardingCompletedKey) ?? false
|
(loadString(service: onboardingCompletedKey) ?? "0") == "1"
|
||||||
}
|
}
|
||||||
|
|
||||||
static func saveHasCompletedOnboarding(_ completed: Bool) {
|
static func saveHasCompletedOnboarding(_ completed: Bool) {
|
||||||
UserDefaults(suiteName: appGroupSuite)?.set(completed, forKey: onboardingCompletedKey)
|
saveString(completed ? "1" : "0", service: onboardingCompletedKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: Road distances (Apple-Maps-matched, computed by the app)
|
// MARK: Road distances (Apple-Maps-matched, computed by the app)
|
||||||
|
|||||||
Reference in New Issue
Block a user