mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-07-25 18:45:20 +00:00
Notes counter UX: avoid grey flicker when closing sheet\n\n- Preserve last count during resubscribe to prevent brief 0 state.\n- Keep existing subscription when building geohash temporarily unavailable; only cancel if none or permission revoked.
This commit is contained in:
@@ -17,9 +17,10 @@ final class LocationNotesCounter: ObservableObject {
|
|||||||
func subscribe(geohash gh: String) {
|
func subscribe(geohash gh: String) {
|
||||||
let norm = gh.lowercased()
|
let norm = gh.lowercased()
|
||||||
if geohash == norm { return }
|
if geohash == norm { return }
|
||||||
|
// Do not clear count immediately to avoid UI flicker; keep last known
|
||||||
|
// value until initial load completes on the new subscription.
|
||||||
cancel()
|
cancel()
|
||||||
geohash = norm
|
geohash = norm
|
||||||
count = 0
|
|
||||||
noteIDs.removeAll()
|
noteIDs.removeAll()
|
||||||
initialLoadComplete = false
|
initialLoadComplete = false
|
||||||
|
|
||||||
|
|||||||
@@ -1530,8 +1530,16 @@ extension ContentView {
|
|||||||
if locationManager.permissionState == .authorized {
|
if locationManager.permissionState == .authorized {
|
||||||
LocationChannelManager.shared.refreshChannels()
|
LocationChannelManager.shared.refreshChannels()
|
||||||
}
|
}
|
||||||
if let building = LocationChannelManager.shared.availableChannels.first(where: { $0.level == .building })?.geohash {
|
if locationManager.permissionState == .authorized {
|
||||||
LocationNotesCounter.shared.subscribe(geohash: building)
|
if let building = LocationChannelManager.shared.availableChannels.first(where: { $0.level == .building })?.geohash {
|
||||||
|
LocationNotesCounter.shared.subscribe(geohash: building)
|
||||||
|
} else {
|
||||||
|
// Keep existing subscription if we had one to avoid flicker
|
||||||
|
// Only cancel if we have no known geohash
|
||||||
|
if LocationNotesCounter.shared.geohash == nil {
|
||||||
|
LocationNotesCounter.shared.cancel()
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
LocationNotesCounter.shared.cancel()
|
LocationNotesCounter.shared.cancel()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user