Improve relay tracking with thunks, add/rename some kinds
This commit is contained in:
@@ -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))
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user