mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-07-25 08:45:19 +00:00
Geohash count: use the same pruned/sorted list for toolbar and peer list (visibleGeohashPeople) to ensure consistency
This commit is contained in:
@@ -1473,6 +1473,17 @@ class ChatViewModel: ObservableObject, BitchatDelegate {
|
||||
|
||||
// MARK: - Public helpers (iOS)
|
||||
#if os(iOS)
|
||||
/// Return the current, pruned, sorted people list for the active geohash without mutating state.
|
||||
@MainActor
|
||||
func visibleGeohashPeople() -> [GeoPerson] {
|
||||
guard let gh = currentGeohash else { return [] }
|
||||
let cutoff = Date().addingTimeInterval(-5 * 60)
|
||||
let map = (geoParticipants[gh] ?? [:]).filter { $0.value >= cutoff }
|
||||
let people = map
|
||||
.map { (pub, seen) in GeoPerson(id: pub, displayName: displayNameForNostrPubkey(pub), lastSeen: seen) }
|
||||
.sorted { $0.lastSeen > $1.lastSeen }
|
||||
return people
|
||||
}
|
||||
/// Returns the current participant count for a specific geohash, using the 5-minute activity window.
|
||||
@MainActor
|
||||
func geohashParticipantCount(for geohash: String) -> Int {
|
||||
|
||||
@@ -871,8 +871,12 @@ struct ContentView: View {
|
||||
// Unread icon immediately to the left of the channel badge (independent from channel button)
|
||||
#if os(iOS)
|
||||
let cc = channelPeopleCountAndColor()
|
||||
let otherPeersCount = cc.0
|
||||
var otherPeersCount = cc.0
|
||||
let countColor = cc.1
|
||||
// Ensure geohash count matches the actual pruned list used in the sidebar
|
||||
if case .location = locationManager.selectedChannel {
|
||||
otherPeersCount = viewModel.visibleGeohashPeople().count
|
||||
}
|
||||
#else
|
||||
let peerCounts = viewModel.allPeers.reduce(into: (others: 0, mesh: 0)) { counts, peer in
|
||||
guard peer.id != viewModel.meshService.myPeerID else { return }
|
||||
|
||||
@@ -24,7 +24,7 @@ struct GeohashPeopleList: View {
|
||||
}
|
||||
return nil
|
||||
}()
|
||||
let ordered = viewModel.geohashPeople.sorted { a, b in
|
||||
let ordered = viewModel.visibleGeohashPeople().sorted { a, b in
|
||||
if let me = myHex {
|
||||
if a.id == me && b.id != me { return true }
|
||||
if b.id == me && a.id != me { return false }
|
||||
|
||||
Reference in New Issue
Block a user