From 602e93d1b292520f23a619b18406086ce41fc52d Mon Sep 17 00:00:00 2001 From: jack Date: Thu, 21 Aug 2025 00:46:53 +0200 Subject: [PATCH] Location sheet: poll for location at regular intervals while open (replace significant-move updates) --- bitchat/Services/LocationChannelManager.swift | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/bitchat/Services/LocationChannelManager.swift b/bitchat/Services/LocationChannelManager.swift index 5c725221..85e1eb63 100644 --- a/bitchat/Services/LocationChannelManager.swift +++ b/bitchat/Services/LocationChannelManager.swift @@ -79,15 +79,20 @@ final class LocationChannelManager: NSObject, CLLocationManagerDelegate, Observa /// Begin periodic one-shot location refreshes while a selector UI is visible. func beginLiveRefresh(interval: TimeInterval = 5.0) { - // Prefer continuous updates with a significant distance filter rather than polling guard permissionState == .authorized else { return } - cl.desiredAccuracy = kCLLocationAccuracyHundredMeters - cl.distanceFilter = 21 // meters; update on small moves - cl.startUpdatingLocation() + // Switch to a lightweight periodic one-shot request (polling) while the sheet is open + refreshTimer?.invalidate() + refreshTimer = Timer.scheduledTimer(withTimeInterval: interval, repeats: true) { [weak self] _ in + self?.requestOneShotLocation() + } + // Kick off immediately + requestOneShotLocation() } /// Stop periodic refreshes when selector UI is dismissed. func endLiveRefresh() { + refreshTimer?.invalidate() + refreshTimer = nil cl.stopUpdatingLocation() }