From bef4a30ea7acd7702bc8288bee48f2900dbd8ec7 Mon Sep 17 00:00:00 2001 From: jack Date: Sat, 13 Sep 2025 01:09:35 +0200 Subject: [PATCH] Location notes: fix intermittent first load by ensuring resubscribe after geohash change, removing over-eager subscribe guard, and widening note fetch window (no since filter) --- bitchat/Services/LocationNotesManager.swift | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/bitchat/Services/LocationNotesManager.swift b/bitchat/Services/LocationNotesManager.swift index db0d36e5..0c5774de 100644 --- a/bitchat/Services/LocationNotesManager.swift +++ b/bitchat/Services/LocationNotesManager.swift @@ -38,6 +38,7 @@ final class LocationNotesManager: ObservableObject { guard norm != geohash else { return } if let sub = subscriptionID { NostrRelayManager.shared.unsubscribe(id: sub) + subscriptionID = nil } geohash = norm notes.removeAll() @@ -45,8 +46,6 @@ final class LocationNotesManager: ObservableObject { } private func subscribe() { - // Avoid double subscription for the same geohash while active - if subscriptionID != nil { return } // Begin loading: always display Matrix for a randomized 1–3 seconds isLoading = true loadingStartedAt = Date() @@ -54,8 +53,8 @@ final class LocationNotesManager: ObservableObject { loadingWorkItem?.cancel() let subID = "locnotes-\(geohash)-\(UUID().uuidString.prefix(8))" subscriptionID = subID - let lookback = Date().addingTimeInterval(-TransportConfig.nostrGeohashInitialLookbackSeconds) - let filter = NostrFilter.geohashNotes(geohash, since: lookback, limit: 200) + // For persistent notes, allow relays to return recent history without an aggressive time cutoff + let filter = NostrFilter.geohashNotes(geohash, since: nil, limit: 200) let relays = GeoRelayDirectory.shared.closestRelays(toGeohash: geohash, count: TransportConfig.nostrGeoRelayCount) NostrRelayManager.shared.subscribe(filter: filter, id: subID, relayUrls: relays) { [weak self] event in guard let self = self else { return }