Refresh participant state for blocked events

This commit is contained in:
vekovius 2026-08-05 15:46:01 -05:00
parent 90973af3f2
commit 968a0ff1e7
2 changed files with 18 additions and 1 deletions

View File

@ -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()

View File

@ -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()