mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-07-25 08:25:21 +00:00
Notes header: show building name when available (fallback to block name)
This commit is contained in:
@@ -52,6 +52,7 @@ struct ContentView: View {
|
||||
@State private var expandedMessageIDs: Set<String> = []
|
||||
@State private var showLocationNotes = false
|
||||
@State private var notesGeohash: String? = nil
|
||||
@State private var notesRefreshTimer: Timer? = nil
|
||||
// Window sizes for rendering (infinite scroll up)
|
||||
@State private var windowCountPublic: Int = 300
|
||||
@State private var windowCountPrivate: [String: Int] = [:]
|
||||
@@ -1269,12 +1270,25 @@ struct ContentView: View {
|
||||
.background(backgroundColor)
|
||||
.foregroundColor(textColor)
|
||||
.onChange(of: locationManager.availableChannels) { channels in
|
||||
if notesGeohash == nil, let building = channels.first(where: { $0.level == .building }) {
|
||||
notesGeohash = building.geohash
|
||||
if let building = channels.first(where: { $0.level == .building }) {
|
||||
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() }
|
||||
.onChange(of: locationManager.selectedChannel) { _ in updateNotesCounterSubscription() }
|
||||
|
||||
@@ -44,7 +44,11 @@ struct LocationNotesView: View {
|
||||
VStack(alignment: .leading, spacing: 2) {
|
||||
Text("notes @ #\(geohash)")
|
||||
.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)
|
||||
.font(.system(size: 12, design: .monospaced))
|
||||
.foregroundColor(secondaryTextColor)
|
||||
|
||||
Reference in New Issue
Block a user