From eb63a62590d7df4a514226c145a19e903c144965 Mon Sep 17 00:00:00 2001 From: jack Date: Sat, 13 Sep 2025 11:29:49 +0200 Subject: [PATCH] Revert notes geohash selection back to block-level (precision 7); keep building level available but unused; update counter and sheet accordingly --- bitchat/Views/ContentView.swift | 25 +++++++++++------------ bitchat/Views/LocationChannelsSheet.swift | 5 +---- bitchat/Views/LocationNotesSheet.swift | 6 +++--- 3 files changed, 16 insertions(+), 20 deletions(-) diff --git a/bitchat/Views/ContentView.swift b/bitchat/Views/ContentView.swift index f518559b..bca748ad 100644 --- a/bitchat/Views/ContentView.swift +++ b/bitchat/Views/ContentView.swift @@ -469,15 +469,14 @@ struct ContentView: View { guard (2...12).contains(gh.count), gh.allSatisfy({ allowed.contains($0) }) else { return } func levelForLength(_ len: Int) -> GeohashChannelLevel { switch len { - case 0...2: return .region - case 3...4: return .province - case 5: return .city - case 6: return .neighborhood + case 0...2: return .region + case 3...4: return .province + case 5: return .city + case 6: return .neighborhood case 7: return .block - case 8: return .building - default: return .building + default: return .block + } } - } let level = levelForLength(gh.count) let ch = GeohashChannel(level: level, geohash: gh) // Do not mark teleported when opening a geohash that is in our regional set. @@ -1181,7 +1180,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 == .building })?.geohash + notesGeohash = LocationChannelManager.shared.availableChannels.first(where: { $0.level == .block })?.geohash showLocationNotes = true }) { HStack(spacing: 4) { @@ -1232,7 +1231,7 @@ struct ContentView: View { } .sheet(isPresented: $showLocationNotes) { Group { - if let gh = notesGeohash ?? LocationChannelManager.shared.availableChannels.first(where: { $0.level == .building })?.geohash { + if let gh = notesGeohash ?? LocationChannelManager.shared.availableChannels.first(where: { $0.level == .block })?.geohash { LocationNotesView(geohash: gh) .environmentObject(viewModel) } else { @@ -1266,8 +1265,8 @@ struct ContentView: View { .background(backgroundColor) .foregroundColor(textColor) .onChange(of: locationManager.availableChannels) { channels in - if notesGeohash == nil, let building = channels.first(where: { $0.level == .building }) { - notesGeohash = building.geohash + if notesGeohash == nil, let block = channels.first(where: { $0.level == .block }) { + notesGeohash = block.geohash } } } @@ -1479,8 +1478,8 @@ extension ContentView { private func updateNotesCounterSubscription() { switch locationManager.selectedChannel { case .mesh: - if let building = LocationChannelManager.shared.availableChannels.first(where: { $0.level == .building })?.geohash { - LocationNotesCounter.shared.subscribe(geohash: building) + if let block = LocationChannelManager.shared.availableChannels.first(where: { $0.level == .block })?.geohash { + LocationNotesCounter.shared.subscribe(geohash: block) } else { LocationNotesCounter.shared.cancel() } diff --git a/bitchat/Views/LocationChannelsSheet.swift b/bitchat/Views/LocationChannelsSheet.swift index 3e4cca59..19ab4a26 100644 --- a/bitchat/Views/LocationChannelsSheet.swift +++ b/bitchat/Views/LocationChannelsSheet.swift @@ -381,8 +381,7 @@ struct LocationChannelsSheet: View { case 5: return .city case 6: return .neighborhood case 7: return .block - case 8: return .building - default: return .building + default: return .block } } } @@ -463,8 +462,6 @@ extension LocationChannelsSheet { switch level { case .region: return "" - case .building: - return "" default: return "~" } diff --git a/bitchat/Views/LocationNotesSheet.swift b/bitchat/Views/LocationNotesSheet.swift index a963cf10..8def19b2 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 == .building })?.geohash { + if let gh = notesGeohash ?? locationManager.availableChannels.first(where: { $0.level == .block })?.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 building = channels.first(where: { $0.level == .building }) { - notesGeohash = building.geohash + if notesGeohash == nil, let block = channels.first(where: { $0.level == .block }) { + notesGeohash = block.geohash } } }