From 24cebfebf256049c3676f0fdc91e18a8209d42a2 Mon Sep 17 00:00:00 2001 From: jack Date: Sat, 13 Sep 2025 12:47:23 +0200 Subject: [PATCH] Notes header: bold count text; ensure sheet updates when building geohash changes by calling manager.setGeohash on geohash change --- bitchat/Views/ContentView.swift | 27 ++++++++++++++++++++++++--- bitchat/Views/LocationNotesView.swift | 5 ++++- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/bitchat/Views/ContentView.swift b/bitchat/Views/ContentView.swift index b8d76b7e..10d0b4a7 100644 --- a/bitchat/Views/ContentView.swift +++ b/bitchat/Views/ContentView.swift @@ -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: { diff --git a/bitchat/Views/LocationNotesView.swift b/bitchat/Views/LocationNotesView.swift index e35b8346..52ecc4bb 100644 --- a/bitchat/Views/LocationNotesView.swift +++ b/bitchat/Views/LocationNotesView.swift @@ -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)) }