Improve relay tracking with thunks, add/rename some kinds

This commit is contained in:
Jon Staab
2025-10-24 06:41:56 -07:00
parent c026084635
commit a03a289e93
6 changed files with 29 additions and 20 deletions
+9 -1
View File
@@ -136,7 +136,6 @@ export class Thunk {
...this.options,
event,
onSuccess: (result: PublishResult) => {
tracker.track(event.id, result.relay)
this.options.onSuccess?.(result)
this.results[result.relay] = result
this._notify()
@@ -150,6 +149,10 @@ export class Thunk {
onTimeout: this._setTimeout,
onAborted: this._setAborted,
onComplete: (result: PublishResult) => {
if (result.status !== PublishStatus.Success) {
tracker.removeRelay(event.id, result.relay)
}
this.options.onComplete?.(result)
this._subs = []
},
@@ -201,6 +204,11 @@ export class Thunk {
enqueue() {
thunkQueue.push(this)
for (const url of this.options.relays) {
tracker.track(this.event.id, url)
}
repository.publish(this.event)
thunks.update($thunks => append(this, $thunks))
+2 -2
View File
@@ -17,7 +17,7 @@ export type MakeUserDataOptions<T> = {
loadItem: UserDataLoader
}
const makeUserData = <T>({mapStore, loadItem}: MakeUserDataOptions<T>) =>
export const makeUserData = <T>({mapStore, loadItem}: MakeUserDataOptions<T>) =>
withGetter(
derived([mapStore, pubkey], ([$mapStore, $pubkey]) => {
if (!$pubkey) return undefined
@@ -28,7 +28,7 @@ const makeUserData = <T>({mapStore, loadItem}: MakeUserDataOptions<T>) =>
}),
)
const makeUserLoader =
export const makeUserLoader =
(loadItem: UserDataLoader) =>
async (relays: string[] = [], force = false) => {
const $pubkey = pubkey.get()