Add chat undo

This commit is contained in:
Jon Staab
2024-10-17 11:27:17 -07:00
parent db0dbbf428
commit d00bc64ffd
5 changed files with 102 additions and 92 deletions

View File

@@ -27,6 +27,7 @@ import {
signer,
repository,
publishThunk,
mergeThunks,
loadProfile,
loadInboxRelaySelections,
profilesByPubkey,
@@ -253,21 +254,24 @@ export const attemptRelayAccess = async (url: string, claim = "") =>
export const sendWrapped = async ({
template,
pubkeys,
delay,
}: {
template: EventTemplate
pubkeys: string[]
delay?: number
}) => {
const nip59 = Nip59.fromSigner(signer.get()!)
await Promise.all(
uniq(pubkeys).map(async recipient => {
const thunk = publishThunk({
event: await nip59.wrap(recipient, stamp(template)),
relays: ctx.app.router.PublishMessage(recipient).getUrls(),
})
await thunk.result
}),
return mergeThunks(
await Promise.all(
uniq(pubkeys).map(async recipient =>
publishThunk({
event: await nip59.wrap(recipient, stamp(template)),
relays: ctx.app.router.PublishMessage(recipient).getUrls(),
delay,
})
),
)
)
}