Split up tracker event types

This commit is contained in:
Jon Staab
2025-05-05 10:52:35 -07:00
parent 19f8e2ecb4
commit 45721bfcb8
6 changed files with 39 additions and 48 deletions
+5 -4
View File
@@ -1,5 +1,6 @@
import {Emitter, addToMapKey} from "@welshman/lib"
export class Tracker extends Emitter {
relaysById = new Map<string, Set<string>>()
idsByRelay = new Map<string, Set<string>>()
@@ -36,7 +37,7 @@ export class Tracker extends Emitter {
this.relaysById.set(eventId, relays)
this.idsByRelay.set(relay, ids)
this.emit("update")
this.emit("add", eventId, relay)
}
removeRelay = (eventId: string, relay: string) => {
@@ -45,7 +46,7 @@ export class Tracker extends Emitter {
if (!didDeleteRelay && !didDeleteId) return
this.emit("update")
this.emit("remove", eventId, relay)
}
track = (eventId: string, relay: string) => {
@@ -73,13 +74,13 @@ export class Tracker extends Emitter {
}
}
this.emit("update")
this.emit("load")
}
clear = () => {
this.relaysById.clear()
this.idsByRelay.clear()
this.emit("update")
this.emit("clear")
}
}