From c7d8c95f8d2993e12437c85a6fac8d80461e31f9 Mon Sep 17 00:00:00 2001 From: jack Date: Sat, 13 Sep 2025 22:28:50 +0200 Subject: [PATCH] Notes: standardize on building-level (8 chars) for publish/read\n\n- Use .building geohash when opening notes, reacting to channel updates, and subscribing the counter.\n- Update comments to reflect building-level scope. --- bitchat/Services/LocationNotesCounter.swift | 2 +- bitchat/Views/ContentView.swift | 12 ++++++------ bitchat/Views/LocationNotesSheet.swift | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/bitchat/Services/LocationNotesCounter.swift b/bitchat/Services/LocationNotesCounter.swift index 6e51a0ff..787bd97c 100644 --- a/bitchat/Services/LocationNotesCounter.swift +++ b/bitchat/Services/LocationNotesCounter.swift @@ -1,6 +1,6 @@ import Foundation -/// Lightweight background counter for location notes (kind 1) at block-level geohash. +/// Lightweight background counter for location notes (kind 1) at building-level geohash (8 chars). @MainActor final class LocationNotesCounter: ObservableObject { static let shared = LocationNotesCounter() diff --git a/bitchat/Views/ContentView.swift b/bitchat/Views/ContentView.swift index e0a904b8..f397f862 100644 --- a/bitchat/Views/ContentView.swift +++ b/bitchat/Views/ContentView.swift @@ -1186,7 +1186,7 @@ struct ContentView: View { LocationChannelManager.shared.enableLocationChannels() LocationChannelManager.shared.refreshChannels() // If we already have a block geohash, pass it; otherwise wait in the sheet. - notesGeohash = LocationChannelManager.shared.availableChannels.first(where: { $0.level == .block })?.geohash + notesGeohash = LocationChannelManager.shared.availableChannels.first(where: { $0.level == .building })?.geohash showLocationNotes = true }) { HStack(alignment: .center, spacing: 4) { @@ -1240,7 +1240,7 @@ struct ContentView: View { } .sheet(isPresented: $showLocationNotes) { Group { - if let gh = notesGeohash ?? LocationChannelManager.shared.availableChannels.first(where: { $0.level == .block })?.geohash { + if let gh = notesGeohash ?? LocationChannelManager.shared.availableChannels.first(where: { $0.level == .building })?.geohash { LocationNotesView(geohash: gh, onNotesCountChanged: { cnt in sheetNotesCount = cnt }) .environmentObject(viewModel) } else { @@ -1286,8 +1286,8 @@ struct ContentView: View { sheetNotesCount = 0 } .onChange(of: locationManager.availableChannels) { channels in - if let current = channels.first(where: { $0.level == .block })?.geohash, - notesGeohash != current { + if let current = channels.first(where: { $0.level == .building })?.geohash, + notesGeohash != current { notesGeohash = current #if os(iOS) // Light taptic when geohash changes while the sheet is open @@ -1530,8 +1530,8 @@ extension ContentView { if locationManager.permissionState == .authorized { LocationChannelManager.shared.refreshChannels() } - if let block = LocationChannelManager.shared.availableChannels.first(where: { $0.level == .block })?.geohash { - LocationNotesCounter.shared.subscribe(geohash: block) + if let building = LocationChannelManager.shared.availableChannels.first(where: { $0.level == .building })?.geohash { + LocationNotesCounter.shared.subscribe(geohash: building) } else { LocationNotesCounter.shared.cancel() } diff --git a/bitchat/Views/LocationNotesSheet.swift b/bitchat/Views/LocationNotesSheet.swift index 8def19b2..a963cf10 100644 --- a/bitchat/Views/LocationNotesSheet.swift +++ b/bitchat/Views/LocationNotesSheet.swift @@ -13,7 +13,7 @@ struct LocationNotesSheet: View { var body: some View { Group { - if let gh = notesGeohash ?? locationManager.availableChannels.first(where: { $0.level == .block })?.geohash { + if let gh = notesGeohash ?? locationManager.availableChannels.first(where: { $0.level == .building })?.geohash { // Found block geohash: show notes view LocationNotesView(geohash: gh) .environmentObject(viewModel) @@ -55,8 +55,8 @@ struct LocationNotesSheet: View { LocationChannelManager.shared.refreshChannels() } .onChange(of: locationManager.availableChannels) { channels in - if notesGeohash == nil, let block = channels.first(where: { $0.level == .block }) { - notesGeohash = block.geohash + if notesGeohash == nil, let building = channels.first(where: { $0.level == .building }) { + notesGeohash = building.geohash } } }