Notes header: show building name when available (fallback to block name)

This commit is contained in:
jack
2025-09-13 12:04:14 +02:00
parent f10e5d1788
commit 8cc6d538ae
2 changed files with 21 additions and 3 deletions
+16 -2
View File
@@ -52,6 +52,7 @@ struct ContentView: View {
@State private var expandedMessageIDs: Set<String> = [] @State private var expandedMessageIDs: Set<String> = []
@State private var showLocationNotes = false @State private var showLocationNotes = false
@State private var notesGeohash: String? = nil @State private var notesGeohash: String? = nil
@State private var notesRefreshTimer: Timer? = nil
// Window sizes for rendering (infinite scroll up) // Window sizes for rendering (infinite scroll up)
@State private var windowCountPublic: Int = 300 @State private var windowCountPublic: Int = 300
@State private var windowCountPrivate: [String: Int] = [:] @State private var windowCountPrivate: [String: Int] = [:]
@@ -1269,12 +1270,25 @@ 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 let building = channels.first(where: { $0.level == .building }) {
notesGeohash = building.geohash if notesGeohash != building.geohash { notesGeohash = building.geohash }
} }
} }
} }
} }
.onAppear {
// Ensure we are authorized and start periodic refresh while the sheet is open
LocationChannelManager.shared.enableLocationChannels()
LocationChannelManager.shared.refreshChannels()
notesRefreshTimer?.invalidate()
notesRefreshTimer = Timer.scheduledTimer(withTimeInterval: 10.0, repeats: true) { _ in
LocationChannelManager.shared.refreshChannels()
}
}
.onDisappear {
notesRefreshTimer?.invalidate()
notesRefreshTimer = nil
}
} }
.onAppear { updateNotesCounterSubscription() } .onAppear { updateNotesCounterSubscription() }
.onChange(of: locationManager.selectedChannel) { _ in updateNotesCounterSubscription() } .onChange(of: locationManager.selectedChannel) { _ in updateNotesCounterSubscription() }
+5 -1
View File
@@ -44,7 +44,11 @@ struct LocationNotesView: View {
VStack(alignment: .leading, spacing: 2) { VStack(alignment: .leading, spacing: 2) {
Text("notes @ #\(geohash)") Text("notes @ #\(geohash)")
.font(.system(size: 16, weight: .bold, design: .monospaced)) .font(.system(size: 16, weight: .bold, design: .monospaced))
if let blockName = locationManager.locationNames[.block], !blockName.isEmpty { if let buildingName = locationManager.locationNames[.building], !buildingName.isEmpty {
Text(buildingName)
.font(.system(size: 12, design: .monospaced))
.foregroundColor(secondaryTextColor)
} else if let blockName = locationManager.locationNames[.block], !blockName.isEmpty {
Text(blockName) Text(blockName)
.font(.system(size: 12, design: .monospaced)) .font(.system(size: 12, design: .monospaced))
.foregroundColor(secondaryTextColor) .foregroundColor(secondaryTextColor)