mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-07-25 20:05:19 +00:00
Location sheet: poll for location at regular intervals while open (replace significant-move updates)
This commit is contained in:
@@ -79,15 +79,20 @@ final class LocationChannelManager: NSObject, CLLocationManagerDelegate, Observa
|
|||||||
|
|
||||||
/// Begin periodic one-shot location refreshes while a selector UI is visible.
|
/// Begin periodic one-shot location refreshes while a selector UI is visible.
|
||||||
func beginLiveRefresh(interval: TimeInterval = 5.0) {
|
func beginLiveRefresh(interval: TimeInterval = 5.0) {
|
||||||
// Prefer continuous updates with a significant distance filter rather than polling
|
|
||||||
guard permissionState == .authorized else { return }
|
guard permissionState == .authorized else { return }
|
||||||
cl.desiredAccuracy = kCLLocationAccuracyHundredMeters
|
// Switch to a lightweight periodic one-shot request (polling) while the sheet is open
|
||||||
cl.distanceFilter = 21 // meters; update on small moves
|
refreshTimer?.invalidate()
|
||||||
cl.startUpdatingLocation()
|
refreshTimer = Timer.scheduledTimer(withTimeInterval: interval, repeats: true) { [weak self] _ in
|
||||||
|
self?.requestOneShotLocation()
|
||||||
|
}
|
||||||
|
// Kick off immediately
|
||||||
|
requestOneShotLocation()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Stop periodic refreshes when selector UI is dismissed.
|
/// Stop periodic refreshes when selector UI is dismissed.
|
||||||
func endLiveRefresh() {
|
func endLiveRefresh() {
|
||||||
|
refreshTimer?.invalidate()
|
||||||
|
refreshTimer = nil
|
||||||
cl.stopUpdatingLocation()
|
cl.stopUpdatingLocation()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user