2026-07-08 17:29:56 +00:00
|
|
|
import {goto} from "$app/navigation"
|
|
|
|
|
import type {TrustedEvent} from "@welshman/util"
|
|
|
|
|
import {setKey} from "@lib/implicit"
|
2026-07-28 16:16:26 +00:00
|
|
|
import {relays} from "@app/core"
|
2026-07-08 17:29:56 +00:00
|
|
|
import {pushModal} from "@app/modal"
|
|
|
|
|
import {makeSpaceChatPath} from "@app/routes"
|
2026-07-28 16:16:26 +00:00
|
|
|
import EventShare from "@app/components/EventShare.svelte"
|
2026-07-08 17:29:56 +00:00
|
|
|
|
|
|
|
|
// Share an event to chat. On NIP-29 relays we prompt for a room to share into;
|
|
|
|
|
// otherwise we stash the event and jump to the space chat composer, which quotes it.
|
|
|
|
|
export const shareEventToChat = (url: string, noun: string, event: TrustedEvent) => {
|
2026-07-28 16:16:26 +00:00
|
|
|
if (relays.get().get(url)?.hasNip(29)) {
|
2026-07-08 17:29:56 +00:00
|
|
|
pushModal(EventShare, {url, noun, event})
|
|
|
|
|
} else {
|
|
|
|
|
setKey("share", event)
|
|
|
|
|
goto(makeSpaceChatPath(url))
|
|
|
|
|
}
|
|
|
|
|
}
|