2024-10-15 21:00:15 +00:00
|
|
|
<script lang="ts">
|
2026-07-28 16:16:26 +00:00
|
|
|
import {onMount} from "svelte"
|
2025-04-09 22:32:18 +00:00
|
|
|
import * as nip19 from "nostr-tools/nip19"
|
2025-07-22 17:10:20 +00:00
|
|
|
import {LOCALE, secondsToDate} from "@welshman/lib"
|
2025-03-03 20:10:47 +00:00
|
|
|
import type {TrustedEvent} from "@welshman/util"
|
2026-07-28 16:16:26 +00:00
|
|
|
import {displayRelayUrl, seen, toNostrURI} from "@welshman/util"
|
2025-09-10 22:26:39 +00:00
|
|
|
import FileText from "@assets/icons/file-text.svg?dataurl"
|
|
|
|
|
import Copy from "@assets/icons/copy.svg?dataurl"
|
|
|
|
|
import UserCircle from "@assets/icons/user-circle.svg?dataurl"
|
2024-10-17 23:17:49 +00:00
|
|
|
import Icon from "@lib/components/Icon.svelte"
|
|
|
|
|
import FieldInline from "@lib/components/FieldInline.svelte"
|
2024-10-15 22:52:30 +00:00
|
|
|
import Button from "@lib/components/Button.svelte"
|
2026-06-24 20:56:53 +00:00
|
|
|
import Badge from "@lib/components/Badge.svelte"
|
2026-01-30 22:14:12 +00:00
|
|
|
import Modal from "@lib/components/Modal.svelte"
|
|
|
|
|
import ModalBody from "@lib/components/ModalBody.svelte"
|
2024-10-15 21:00:15 +00:00
|
|
|
import ModalHeader from "@lib/components/ModalHeader.svelte"
|
2026-02-03 19:00:13 +00:00
|
|
|
import ModalFooter from "@lib/components/ModalFooter.svelte"
|
2026-02-02 18:09:14 +00:00
|
|
|
import ModalTitle from "@lib/components/ModalTitle.svelte"
|
|
|
|
|
import ModalSubtitle from "@lib/components/ModalSubtitle.svelte"
|
2026-07-28 16:16:26 +00:00
|
|
|
import {app, router} from "@app/core"
|
2026-06-08 21:14:40 +00:00
|
|
|
import {clip} from "@app/toast"
|
2024-10-15 21:00:15 +00:00
|
|
|
|
2025-03-03 20:10:47 +00:00
|
|
|
type Props = {
|
|
|
|
|
url?: string
|
|
|
|
|
event: TrustedEvent
|
|
|
|
|
}
|
2024-10-17 23:17:49 +00:00
|
|
|
|
2025-03-03 20:10:47 +00:00
|
|
|
const {url, event}: Props = $props()
|
|
|
|
|
|
2026-07-28 16:16:26 +00:00
|
|
|
const seenOn = $app.tracker.getRelays(event.id)
|
2024-10-17 23:17:49 +00:00
|
|
|
const npub1 = nip19.npubEncode(event.pubkey)
|
|
|
|
|
const json = JSON.stringify(event, null, 2)
|
2024-11-19 21:24:18 +00:00
|
|
|
const copyLink = () => clip(nevent1)
|
2024-10-17 23:17:49 +00:00
|
|
|
const copyPubkey = () => clip(npub1)
|
|
|
|
|
const copyJson = () => clip(json)
|
2026-07-27 22:38:23 +00:00
|
|
|
const back = () => history.back()
|
2025-07-22 17:10:20 +00:00
|
|
|
|
|
|
|
|
const formatter = new Intl.DateTimeFormat(LOCALE, {
|
|
|
|
|
dateStyle: "long",
|
|
|
|
|
timeStyle: "long",
|
|
|
|
|
})
|
2026-07-28 16:16:26 +00:00
|
|
|
|
|
|
|
|
let nevent1 = $state("")
|
|
|
|
|
|
|
|
|
|
onMount(async () => {
|
|
|
|
|
const relays = url ? [url] : await $router.resolver.relays([seen(event)])
|
|
|
|
|
|
|
|
|
|
nevent1 = toNostrURI(nip19.neventEncode({...event, relays}))
|
|
|
|
|
})
|
2024-10-15 21:00:15 +00:00
|
|
|
</script>
|
|
|
|
|
|
2026-01-30 22:14:12 +00:00
|
|
|
<Modal>
|
|
|
|
|
<ModalBody>
|
|
|
|
|
<ModalHeader>
|
2026-02-02 18:09:14 +00:00
|
|
|
<ModalTitle>Event Details</ModalTitle>
|
|
|
|
|
<ModalSubtitle>The full details of this event are shown below.</ModalSubtitle>
|
2026-01-30 22:14:12 +00:00
|
|
|
</ModalHeader>
|
2025-08-04 19:32:44 +00:00
|
|
|
<FieldInline>
|
|
|
|
|
{#snippet label()}
|
2026-01-30 22:14:12 +00:00
|
|
|
<p>Created At</p>
|
2025-08-04 19:32:44 +00:00
|
|
|
{/snippet}
|
|
|
|
|
{#snippet input()}
|
2026-01-30 22:14:12 +00:00
|
|
|
<p>{formatter.format(secondsToDate(event.created_at))}</p>
|
2025-08-04 19:32:44 +00:00
|
|
|
{/snippet}
|
|
|
|
|
</FieldInline>
|
2026-01-30 22:14:12 +00:00
|
|
|
<FieldInline>
|
|
|
|
|
{#snippet label()}
|
|
|
|
|
<p>Event Link</p>
|
|
|
|
|
{/snippet}
|
|
|
|
|
{#snippet input()}
|
2026-06-24 20:56:53 +00:00
|
|
|
<label class="input flex w-full items-center gap-2">
|
2026-01-30 22:14:12 +00:00
|
|
|
<Icon icon={FileText} />
|
2026-07-02 21:22:55 +00:00
|
|
|
<input type="text" class="truncate min-w-0 grow" value={nevent1} />
|
2026-01-30 22:14:12 +00:00
|
|
|
<Button onclick={copyLink} class="flex items-center">
|
|
|
|
|
<Icon icon={Copy} />
|
|
|
|
|
</Button>
|
|
|
|
|
</label>
|
|
|
|
|
{/snippet}
|
|
|
|
|
</FieldInline>
|
|
|
|
|
<FieldInline>
|
|
|
|
|
{#snippet label()}
|
|
|
|
|
<p>Author Pubkey</p>
|
|
|
|
|
{/snippet}
|
|
|
|
|
{#snippet input()}
|
2026-06-24 20:56:53 +00:00
|
|
|
<label class="input flex w-full items-center gap-2">
|
2026-01-30 22:14:12 +00:00
|
|
|
<Icon icon={UserCircle} />
|
2026-07-02 21:22:55 +00:00
|
|
|
<input type="text" class="truncate min-w-0 grow" value={npub1} />
|
2026-01-30 22:14:12 +00:00
|
|
|
<Button onclick={copyPubkey} class="flex items-center">
|
|
|
|
|
<Icon icon={Copy} />
|
|
|
|
|
</Button>
|
|
|
|
|
</label>
|
|
|
|
|
{/snippet}
|
|
|
|
|
</FieldInline>
|
|
|
|
|
{#if !url && seenOn.size > 0}
|
|
|
|
|
<FieldInline>
|
|
|
|
|
{#snippet label()}
|
|
|
|
|
<p>Seen On</p>
|
|
|
|
|
{/snippet}
|
|
|
|
|
{#snippet input()}
|
|
|
|
|
<div class="flex flex-wrap gap-2">
|
|
|
|
|
{#each seenOn as url, i (url)}
|
2026-06-24 20:56:53 +00:00
|
|
|
<Badge class="bg-surface flex gap-1">
|
2026-01-30 22:14:12 +00:00
|
|
|
{displayRelayUrl(url)}
|
2026-06-24 20:56:53 +00:00
|
|
|
</Badge>
|
2026-01-30 22:14:12 +00:00
|
|
|
{/each}
|
|
|
|
|
</div>
|
|
|
|
|
{/snippet}
|
|
|
|
|
</FieldInline>
|
|
|
|
|
{/if}
|
|
|
|
|
<div class="relative">
|
2026-06-24 20:56:53 +00:00
|
|
|
<pre class="card card-sm overflow-auto text-xs"><code>{json}</code></pre>
|
2026-04-07 21:53:19 +00:00
|
|
|
<p class="absolute right-2 top-2 flex grow items-center justify-between">
|
2026-06-24 20:56:53 +00:00
|
|
|
<Button onclick={copyJson} class="button button-neutral button-sm flex items-center">
|
2026-01-30 22:14:12 +00:00
|
|
|
<Icon icon={Copy} /> Copy
|
|
|
|
|
</Button>
|
|
|
|
|
</p>
|
|
|
|
|
</div>
|
|
|
|
|
</ModalBody>
|
2026-02-03 19:00:13 +00:00
|
|
|
<ModalFooter>
|
2026-07-27 22:38:23 +00:00
|
|
|
<Button class="button button-primary grow" onclick={back}>Got it</Button>
|
2026-02-03 19:00:13 +00:00
|
|
|
</ModalFooter>
|
2026-01-30 22:14:12 +00:00
|
|
|
</Modal>
|