diff --git a/bitchat/Services/TransportConfig.swift b/bitchat/Services/TransportConfig.swift index 9203a548..8de7a70f 100644 --- a/bitchat/Services/TransportConfig.swift +++ b/bitchat/Services/TransportConfig.swift @@ -103,7 +103,7 @@ enum TransportConfig { // Location static let locationDistanceFilterMeters: Double = 1000 // Live (channel sheet open) distance threshold for meaningful updates - static let locationDistanceFilterLiveMeters: Double = 21.0 + static let locationDistanceFilterLiveMeters: Double = 10.0 static let locationLiveRefreshInterval: TimeInterval = 5.0 // Notifications (geohash) diff --git a/bitchat/Views/ContentView.swift b/bitchat/Views/ContentView.swift index 8b10833d..b8d76b7e 100644 --- a/bitchat/Views/ContentView.swift +++ b/bitchat/Views/ContentView.swift @@ -1185,15 +1185,11 @@ struct ContentView: View { showLocationNotes = true }) { HStack(alignment: .center, spacing: 4) { + let hasNotes = (notesCounter.count ?? 0) > 0 Image(systemName: "long.text.page.and.pencil") .font(.system(size: 12)) - .foregroundColor(Color(hue: 0.60, saturation: 0.85, brightness: 0.82)) + .foregroundColor(hasNotes ? Color(hue: 0.60, saturation: 0.85, brightness: 0.82) : Color.gray) .padding(.top, 1) - Text("\(notesCounter.count ?? 0)") - .font(.system(size: 11, design: .monospaced)) - .foregroundColor(Color(hue: 0.60, saturation: 0.85, brightness: 0.82)) - .lineLimit(1) - .fixedSize(horizontal: true, vertical: false) } .fixedSize(horizontal: true, vertical: false) } @@ -1286,30 +1282,10 @@ struct ContentView: View { LocationChannelManager.shared.endLiveRefresh() } } - .onAppear { - updateNotesCounterSubscription() - // Keep live updates running while on mesh to follow building changes - if case .mesh = locationManager.selectedChannel, locationManager.permissionState == .authorized { - LocationChannelManager.shared.beginLiveRefresh() - } - } - .onChange(of: locationManager.selectedChannel) { _ in - updateNotesCounterSubscription() - if case .mesh = locationManager.selectedChannel, locationManager.permissionState == .authorized { - LocationChannelManager.shared.beginLiveRefresh() - } else { - LocationChannelManager.shared.endLiveRefresh() - } - } + .onAppear { updateNotesCounterSubscription() } + .onChange(of: locationManager.selectedChannel) { _ in updateNotesCounterSubscription() } .onChange(of: locationManager.availableChannels) { _ in updateNotesCounterSubscription() } - .onChange(of: locationManager.permissionState) { _ in - updateNotesCounterSubscription() - if case .mesh = locationManager.selectedChannel, locationManager.permissionState == .authorized { - LocationChannelManager.shared.beginLiveRefresh() - } else { - LocationChannelManager.shared.endLiveRefresh() - } - } + .onChange(of: locationManager.permissionState) { _ in updateNotesCounterSubscription() } .alert("heads up", isPresented: $viewModel.showScreenshotPrivacyWarning) { Button("ok", role: .cancel) {} } message: { diff --git a/bitchat/Views/LocationNotesView.swift b/bitchat/Views/LocationNotesView.swift index caad92eb..0153983f 100644 --- a/bitchat/Views/LocationNotesView.swift +++ b/bitchat/Views/LocationNotesView.swift @@ -42,7 +42,7 @@ struct LocationNotesView: View { private var header: some View { HStack { VStack(alignment: .leading, spacing: 2) { - Text("notes @ #\(geohash)") + Text("notes @ #\(geohash) (\(manager.notes.count))") .font(.system(size: 16, weight: .bold, design: .monospaced)) if let buildingName = locationManager.locationNames[.building], !buildingName.isEmpty { Text(buildingName)