Put tracker in a store

This commit is contained in:
Jon Staab
2024-09-11 14:07:34 -07:00
parent 4e113faa1a
commit c5364b60b8
6 changed files with 65 additions and 7 deletions
+5 -1
View File
@@ -3,7 +3,7 @@ import {Worker, assoc} from '@welshman/lib'
import {stamp, own, hash} from "@welshman/signer"
import type {HashedEvent, EventTemplate, SignedEvent} from '@welshman/util'
import {publish, PublishStatus} from "@welshman/net"
import {repository} from './core'
import {repository, tracker} from './core'
import {pubkey, getSession, getSigner} from './session'
export type PublishStatusData = {
@@ -52,6 +52,10 @@ thunkWorker.addGlobalHandler(async ({event, relays, resolve}: ThunkWithResolve)
assoc(id, Object.assign(statusByUrl, {[url]: {id, url, status, message}})),
)
if (status === PublishStatus.Success) {
tracker.track(id, url)
}
if (
Object.values(statusByUrl).filter(s => s.status !== PublishStatus.Pending).length ===
relays.length