mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-07-25 07:25:19 +00:00
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)
This commit is contained in:
@@ -38,6 +38,7 @@ final class LocationNotesManager: ObservableObject {
|
|||||||
guard norm != geohash else { return }
|
guard norm != geohash else { return }
|
||||||
if let sub = subscriptionID {
|
if let sub = subscriptionID {
|
||||||
NostrRelayManager.shared.unsubscribe(id: sub)
|
NostrRelayManager.shared.unsubscribe(id: sub)
|
||||||
|
subscriptionID = nil
|
||||||
}
|
}
|
||||||
geohash = norm
|
geohash = norm
|
||||||
notes.removeAll()
|
notes.removeAll()
|
||||||
@@ -45,8 +46,6 @@ final class LocationNotesManager: ObservableObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private func subscribe() {
|
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
|
// Begin loading: always display Matrix for a randomized 1–3 seconds
|
||||||
isLoading = true
|
isLoading = true
|
||||||
loadingStartedAt = Date()
|
loadingStartedAt = Date()
|
||||||
@@ -54,8 +53,8 @@ final class LocationNotesManager: ObservableObject {
|
|||||||
loadingWorkItem?.cancel()
|
loadingWorkItem?.cancel()
|
||||||
let subID = "locnotes-\(geohash)-\(UUID().uuidString.prefix(8))"
|
let subID = "locnotes-\(geohash)-\(UUID().uuidString.prefix(8))"
|
||||||
subscriptionID = subID
|
subscriptionID = subID
|
||||||
let lookback = Date().addingTimeInterval(-TransportConfig.nostrGeohashInitialLookbackSeconds)
|
// For persistent notes, allow relays to return recent history without an aggressive time cutoff
|
||||||
let filter = NostrFilter.geohashNotes(geohash, since: lookback, limit: 200)
|
let filter = NostrFilter.geohashNotes(geohash, since: nil, limit: 200)
|
||||||
let relays = GeoRelayDirectory.shared.closestRelays(toGeohash: geohash, count: TransportConfig.nostrGeoRelayCount)
|
let relays = GeoRelayDirectory.shared.closestRelays(toGeohash: geohash, count: TransportConfig.nostrGeoRelayCount)
|
||||||
NostrRelayManager.shared.subscribe(filter: filter, id: subID, relayUrls: relays) { [weak self] event in
|
NostrRelayManager.shared.subscribe(filter: filter, id: subID, relayUrls: relays) { [weak self] event in
|
||||||
guard let self = self else { return }
|
guard let self = self else { return }
|
||||||
|
|||||||
Reference in New Issue
Block a user