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() LocationChannelManager.shared.endLiveRefresh()
} }
} }
.onAppear { updateNotesCounterSubscription() } .onAppear {
.onChange(of: locationManager.selectedChannel) { _ in updateNotesCounterSubscription() } 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.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) { .alert("heads up", isPresented: $viewModel.showScreenshotPrivacyWarning) {
Button("ok", role: .cancel) {} Button("ok", role: .cancel) {}
} message: { } message: {
+4 -1
View File
@@ -37,6 +37,9 @@ struct LocationNotesView: View {
.background(backgroundColor) .background(backgroundColor)
.foregroundColor(textColor) .foregroundColor(textColor)
.onDisappear { manager.cancel() } .onDisappear { manager.cancel() }
.onChange(of: geohash) { newValue in
manager.setGeohash(newValue)
}
} }
private var header: some View { private var header: some View {
@@ -45,7 +48,7 @@ struct LocationNotesView: View {
HStack(spacing: 4) { HStack(spacing: 4) {
let c = manager.notes.count let c = manager.notes.count
Text("\(c) \(c == 1 ? "note" : "notes") ") Text("\(c) \(c == 1 ? "note" : "notes") ")
.font(.system(size: 16, weight: .regular, design: .monospaced)) .font(.system(size: 16, weight: .bold, design: .monospaced))
Text("@ #\(geohash)") Text("@ #\(geohash)")
.font(.system(size: 16, weight: .bold, design: .monospaced)) .font(.system(size: 16, weight: .bold, design: .monospaced))
} }