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
+7 -8
View File
@@ -474,8 +474,7 @@ struct ContentView: View {
case 5: return .city case 5: return .city
case 6: return .neighborhood case 6: return .neighborhood
case 7: return .block case 7: return .block
case 8: return .building default: return .block
default: return .building
} }
} }
let level = levelForLength(gh.count) let level = levelForLength(gh.count)
@@ -1181,7 +1180,7 @@ struct ContentView: View {
LocationChannelManager.shared.enableLocationChannels() LocationChannelManager.shared.enableLocationChannels()
LocationChannelManager.shared.refreshChannels() LocationChannelManager.shared.refreshChannels()
// If we already have a block geohash, pass it; otherwise wait in the sheet. // 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 showLocationNotes = true
}) { }) {
HStack(spacing: 4) { HStack(spacing: 4) {
@@ -1232,7 +1231,7 @@ struct ContentView: View {
} }
.sheet(isPresented: $showLocationNotes) { .sheet(isPresented: $showLocationNotes) {
Group { 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) LocationNotesView(geohash: gh)
.environmentObject(viewModel) .environmentObject(viewModel)
} else { } else {
@@ -1266,8 +1265,8 @@ struct ContentView: View {
.background(backgroundColor) .background(backgroundColor)
.foregroundColor(textColor) .foregroundColor(textColor)
.onChange(of: locationManager.availableChannels) { channels in .onChange(of: locationManager.availableChannels) { channels in
if notesGeohash == nil, let building = channels.first(where: { $0.level == .building }) { if notesGeohash == nil, let block = channels.first(where: { $0.level == .block }) {
notesGeohash = building.geohash notesGeohash = block.geohash
} }
} }
} }
@@ -1479,8 +1478,8 @@ extension ContentView {
private func updateNotesCounterSubscription() { private func updateNotesCounterSubscription() {
switch locationManager.selectedChannel { switch locationManager.selectedChannel {
case .mesh: case .mesh:
if let building = LocationChannelManager.shared.availableChannels.first(where: { $0.level == .building })?.geohash { if let block = LocationChannelManager.shared.availableChannels.first(where: { $0.level == .block })?.geohash {
LocationNotesCounter.shared.subscribe(geohash: building) LocationNotesCounter.shared.subscribe(geohash: block)
} else { } else {
LocationNotesCounter.shared.cancel() LocationNotesCounter.shared.cancel()
} }
+1 -4
View File
@@ -381,8 +381,7 @@ struct LocationChannelsSheet: View {
case 5: return .city case 5: return .city
case 6: return .neighborhood case 6: return .neighborhood
case 7: return .block case 7: return .block
case 8: return .building default: return .block
default: return .building
} }
} }
} }
@@ -463,8 +462,6 @@ extension LocationChannelsSheet {
switch level { switch level {
case .region: case .region:
return "" return ""
case .building:
return ""
default: default:
return "~" return "~"
} }
+3 -3
View File
@@ -13,7 +13,7 @@ struct LocationNotesSheet: View {
var body: some View { var body: some View {
Group { 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 // Found block geohash: show notes view
LocationNotesView(geohash: gh) LocationNotesView(geohash: gh)
.environmentObject(viewModel) .environmentObject(viewModel)
@@ -55,8 +55,8 @@ struct LocationNotesSheet: View {
LocationChannelManager.shared.refreshChannels() LocationChannelManager.shared.refreshChannels()
} }
.onChange(of: locationManager.availableChannels) { channels in .onChange(of: locationManager.availableChannels) { channels in
if notesGeohash == nil, let building = channels.first(where: { $0.level == .building }) { if notesGeohash == nil, let block = channels.first(where: { $0.level == .block }) {
notesGeohash = building.geohash notesGeohash = block.geohash
} }
} }
} }