diff --git a/src/app/commands.ts b/src/app/commands.ts index 42c855d3..2ad7b460 100644 --- a/src/app/commands.ts +++ b/src/app/commands.ts @@ -1,3 +1,4 @@ +import * as nip19 from "nostr-tools/nip19" import {get} from "svelte/store" import {ctx, sample, uniq, sleep, chunk, equals} from "@welshman/lib" import { @@ -27,8 +28,9 @@ import { getRelayTags, isShareableRelayUrl, getRelayTagValues, + toNostrURI, } from "@welshman/util" -import type {TrustedEvent, EventTemplate, List} from "@welshman/util" +import type {TrustedEvent, EventContent, EventTemplate, List} from "@welshman/util" import type {SubscribeRequestWithHandlers} from "@welshman/net" import {PublishStatus, AuthStatus, SocketStatus} from "@welshman/net" import {Nip59, makeSecret, stamp, Nip46Broker} from "@welshman/signer" @@ -56,6 +58,7 @@ import { clearStorage, dropSession, tagEventForComment, + tagEventForQuote, } from "@welshman/app" import type {Thunk} from "@welshman/app" import { @@ -96,6 +99,22 @@ export const getThunkError = async (thunk: Thunk) => { } } +export const prependParent = (parent: TrustedEvent | undefined, {content, tags}: EventContent) => { + if (parent) { + const nevent = nip19.neventEncode({ + id: parent.id, + kind: parent.kind, + author: parent.pubkey, + relays: ctx.app.router.Event(parent).limit(3).getUrls(), + }) + + tags = [...tags, tagEventForQuote(parent)] + content = toNostrURI(nevent) + "\n\n" + content + } + + return {content, tags} +} + // Log in export const loginWithNip46 = async ({ diff --git a/src/app/components/ChannelCompose.svelte b/src/app/components/ChannelCompose.svelte index 170b2e2b..99e4ff8e 100644 --- a/src/app/components/ChannelCompose.svelte +++ b/src/app/components/ChannelCompose.svelte @@ -1,19 +1,19 @@ @@ -51,7 +51,7 @@ {/if}