Add latest note from admin to relay dashboard

This commit is contained in:
Jon Staab
2025-06-04 20:37:48 -07:00
parent d2b7db18af
commit 7d617d8399
2 changed files with 56 additions and 20 deletions
+40
View File
@@ -0,0 +1,40 @@
<script lang="ts">
import type {Snippet} from "svelte"
import {load} from "@welshman/net"
import {NOTE} from "@welshman/util"
import {fly} from "@lib/transition"
import Spinner from "@lib/components/Spinner.svelte"
import NoteItem from "@app/components/NoteItem.svelte"
interface Props {
url: string
pubkey: string
limit?: number
fallback?: Snippet
}
const {url, pubkey, limit = 1, fallback}: Props = $props()
const events = load({
relays: [url],
filters: [{authors: [pubkey], kinds: [NOTE], limit}],
})
</script>
<div class="col-4">
<div class="flex flex-col gap-2">
{#await events}
<p class="center my-12 flex">
<Spinner loading />
</p>
{:then events}
{#each events as event (event.id)}
<div in:fly>
<NoteItem {url} {event} />
</div>
{:else}
{@render fallback?.()}
{/each}
{/await}
</div>
</div>