diff --git a/bitchat/Views/ContentView.swift b/bitchat/Views/ContentView.swift index 213a78c0..2fc55f73 100644 --- a/bitchat/Views/ContentView.swift +++ b/bitchat/Views/ContentView.swift @@ -52,6 +52,7 @@ struct ContentView: View { @State private var expandedMessageIDs: Set = [] @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() } diff --git a/bitchat/Views/LocationNotesView.swift b/bitchat/Views/LocationNotesView.swift index 82f727cd..caad92eb 100644 --- a/bitchat/Views/LocationNotesView.swift +++ b/bitchat/Views/LocationNotesView.swift @@ -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)