Fix notes icon color: subscribe/count at block-level geohash\n\n- Use block (precision 7) geohash for notes: when opening sheet, on channel changes, and when subscribing the counter.\n- Aligns with LocationNotesManager which publishes at street-level geohash, allowing the counter to detect notes and turn icon blue.

This commit is contained in:
jack
2025-09-13 22:26:34 +02:00
parent bd753af6cb
commit 7da6f95e87
+5 -5
View File
@@ -1186,7 +1186,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(alignment: .center, spacing: 4) { HStack(alignment: .center, spacing: 4) {
@@ -1240,7 +1240,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, onNotesCountChanged: { cnt in sheetNotesCount = cnt }) LocationNotesView(geohash: gh, onNotesCountChanged: { cnt in sheetNotesCount = cnt })
.environmentObject(viewModel) .environmentObject(viewModel)
} else { } else {
@@ -1286,7 +1286,7 @@ struct ContentView: View {
sheetNotesCount = 0 sheetNotesCount = 0
} }
.onChange(of: locationManager.availableChannels) { channels in .onChange(of: locationManager.availableChannels) { channels in
if let current = channels.first(where: { $0.level == .building })?.geohash, if let current = channels.first(where: { $0.level == .block })?.geohash,
notesGeohash != current { notesGeohash != current {
notesGeohash = current notesGeohash = current
#if os(iOS) #if os(iOS)
@@ -1530,8 +1530,8 @@ extension ContentView {
if locationManager.permissionState == .authorized { if locationManager.permissionState == .authorized {
LocationChannelManager.shared.refreshChannels() LocationChannelManager.shared.refreshChannels()
} }
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()
} }