mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-08-08 06:56:10 +00:00
Refresh participant state for blocked events
This commit is contained in:
parent
90973af3f2
commit
968a0ff1e7
@ -80,7 +80,10 @@ final class GeohashParticipantTracker: ObservableObject {
|
||||
/// Record activity from a participant in a specific geohash
|
||||
func recordParticipant(pubkeyHex: String, geohash: String) {
|
||||
let key = pubkeyHex.lowercased()
|
||||
guard context?.isBlocked(key) != true else { return }
|
||||
if context?.isBlocked(key) == true {
|
||||
removeParticipant(pubkeyHex: key)
|
||||
return
|
||||
}
|
||||
|
||||
var map = participants[geohash] ?? [:]
|
||||
map[key] = Date()
|
||||
|
||||
@ -158,6 +158,20 @@ struct GeohashParticipantTrackerTests {
|
||||
#expect(tracker.visiblePeople.isEmpty)
|
||||
}
|
||||
|
||||
@Test func recordParticipant_blockedRepeatRemovesStaleVisibleParticipant() {
|
||||
let tracker = GeohashParticipantTracker()
|
||||
let context = MockParticipantContext()
|
||||
tracker.configure(context: context)
|
||||
tracker.setActiveGeohash("abc123")
|
||||
tracker.recordParticipant(pubkeyHex: "later-blocked")
|
||||
|
||||
context.blockedPubkeys.insert("later-blocked")
|
||||
tracker.recordParticipant(pubkeyHex: "LATER-BLOCKED")
|
||||
|
||||
#expect(tracker.participantCount(for: "abc123") == 0)
|
||||
#expect(tracker.visiblePeople.isEmpty)
|
||||
}
|
||||
|
||||
@Test func participantCount_matchesVisiblePeopleWithMixedBlockStatus() {
|
||||
let tracker = GeohashParticipantTracker()
|
||||
let context = MockParticipantContext()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user