From 2b567bfb9798d9ea1728328780713480a18251e1 Mon Sep 17 00:00:00 2001 From: jack Date: Sat, 13 Sep 2025 22:45:43 +0200 Subject: [PATCH] =?UTF-8?q?Notes=20counter:=20unsubscribe=20without=20clea?= =?UTF-8?q?ring=20count=20on=20resubscribe\n\n-=20Avoid=20calling=20cancel?= =?UTF-8?q?()=20in=20subscribe;=20just=20unsubscribe=20old=20sub=20to=20pr?= =?UTF-8?q?event=20wiping=20count=20to=200.\n-=20Prevents=20green=E2=86=92?= =?UTF-8?q?grey=20flicker=20after=20closing=20sheet=20or=20location=20upda?= =?UTF-8?q?tes.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bitchat/Services/LocationNotesCounter.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bitchat/Services/LocationNotesCounter.swift b/bitchat/Services/LocationNotesCounter.swift index 5fb443a5..2e377c4a 100644 --- a/bitchat/Services/LocationNotesCounter.swift +++ b/bitchat/Services/LocationNotesCounter.swift @@ -16,10 +16,10 @@ final class LocationNotesCounter: ObservableObject { func subscribe(geohash gh: String) { let norm = gh.lowercased() - 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() + if geohash == norm, subscriptionID != nil { return } + // Unsubscribe previous without clearing count to avoid flicker + if let sub = subscriptionID { NostrRelayManager.shared.unsubscribe(id: sub) } + subscriptionID = nil geohash = norm noteIDs.removeAll() initialLoadComplete = false