Revert notes geohash selection back to block-level (precision 7); keep building level available but unused; update counter and sheet accordingly

This commit is contained in:
jack
2025-09-13 11:29:49 +02:00
parent 939adcf1cb
commit eb63a62590
3 changed files with 16 additions and 20 deletions
+12 -13
View File
@@ -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()
}
+1 -4
View File
@@ -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 "~"
}
+3 -3
View File
@@ -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
}
}
}