Notes counter: unsubscribe without clearing count on resubscribe\n\n- Avoid calling cancel() in subscribe; just unsubscribe old sub to prevent wiping count to 0.\n- Prevents green→grey flicker after closing sheet or location updates.

This commit is contained in:
jack
2025-09-13 22:45:43 +02:00
parent a6d98de90e
commit 2b567bfb97
+4 -4
View File
@@ -16,10 +16,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, subscriptionID != nil { return }
// Do not clear count immediately to avoid UI flicker; keep last known // Unsubscribe previous without clearing count to avoid flicker
// value until initial load completes on the new subscription. if let sub = subscriptionID { NostrRelayManager.shared.unsubscribe(id: sub) }
cancel() subscriptionID = nil
geohash = norm geohash = norm
noteIDs.removeAll() noteIDs.removeAll()
initialLoadComplete = false initialLoadComplete = false