Notes header: bold count text; ensure sheet updates when building geohash changes by calling manager.setGeohash on geohash change

This commit is contained in:
jack
2025-09-13 12:47:23 +02:00
parent 0a151f51df
commit 24cebfebf2
2 changed files with 28 additions and 4 deletions
+24 -3
View File
@@ -1282,10 +1282,31 @@ struct ContentView: View {
LocationChannelManager.shared.endLiveRefresh()
}
}
.onAppear { updateNotesCounterSubscription() }
.onChange(of: locationManager.selectedChannel) { _ in updateNotesCounterSubscription() }
.onAppear {
updateNotesCounterSubscription()
if case .mesh = locationManager.selectedChannel,
locationManager.permissionState == .authorized,
LocationChannelManager.shared.availableChannels.isEmpty {
LocationChannelManager.shared.refreshChannels()
}
}
.onChange(of: locationManager.selectedChannel) { _ in
updateNotesCounterSubscription()
if case .mesh = locationManager.selectedChannel,
locationManager.permissionState == .authorized,
LocationChannelManager.shared.availableChannels.isEmpty {
LocationChannelManager.shared.refreshChannels()
}
}
.onChange(of: locationManager.availableChannels) { _ in updateNotesCounterSubscription() }
.onChange(of: locationManager.permissionState) { _ in updateNotesCounterSubscription() }
.onChange(of: locationManager.permissionState) { _ in
updateNotesCounterSubscription()
if case .mesh = locationManager.selectedChannel,
locationManager.permissionState == .authorized,
LocationChannelManager.shared.availableChannels.isEmpty {
LocationChannelManager.shared.refreshChannels()
}
}
.alert("heads up", isPresented: $viewModel.showScreenshotPrivacyWarning) {
Button("ok", role: .cancel) {}
} message: {
+4 -1
View File
@@ -37,6 +37,9 @@ struct LocationNotesView: View {
.background(backgroundColor)
.foregroundColor(textColor)
.onDisappear { manager.cancel() }
.onChange(of: geohash) { newValue in
manager.setGeohash(newValue)
}
}
private var header: some View {
@@ -45,7 +48,7 @@ struct LocationNotesView: View {
HStack(spacing: 4) {
let c = manager.notes.count
Text("\(c) \(c == 1 ? "note" : "notes") ")
.font(.system(size: 16, weight: .regular, design: .monospaced))
.font(.system(size: 16, weight: .bold, design: .monospaced))
Text("@ #\(geohash)")
.font(.system(size: 16, weight: .bold, design: .monospaced))
}