2025-07-07 22:28:36 +00:00
|
|
|
<script lang="ts">
|
2026-07-28 16:16:26 +00:00
|
|
|
import {derived} from "svelte/store"
|
2025-07-07 22:28:36 +00:00
|
|
|
import {onMount} from "svelte"
|
|
|
|
|
import {page} from "$app/stores"
|
2025-11-20 23:54:06 +00:00
|
|
|
import {sleep} from "@welshman/lib"
|
2025-10-13 20:35:02 +00:00
|
|
|
import type {MakeNonOptional} from "@welshman/lib"
|
2026-07-28 16:16:26 +00:00
|
|
|
import {COMMENT} from "@welshman/util"
|
|
|
|
|
import {deriveEventsAsc} from "@welshman/store"
|
|
|
|
|
import {ZapGoal} from "@welshman/domain"
|
2025-09-10 22:26:39 +00:00
|
|
|
import SortVertical from "@assets/icons/sort-vertical.svg?dataurl"
|
|
|
|
|
import Reply from "@assets/icons/reply-2.svg?dataurl"
|
2025-07-07 22:28:36 +00:00
|
|
|
import Icon from "@lib/components/Icon.svelte"
|
|
|
|
|
import PageContent from "@lib/components/PageContent.svelte"
|
|
|
|
|
import Spinner from "@lib/components/Spinner.svelte"
|
|
|
|
|
import Button from "@lib/components/Button.svelte"
|
2026-03-12 23:41:07 +00:00
|
|
|
import SpaceBar from "@app/components/SpaceBar.svelte"
|
2026-02-03 22:18:58 +00:00
|
|
|
import NoteContent from "@app/components/NoteContent.svelte"
|
2025-07-07 22:28:36 +00:00
|
|
|
import NoteCard from "@app/components/NoteCard.svelte"
|
|
|
|
|
import GoalActions from "@app/components/GoalActions.svelte"
|
|
|
|
|
import CommentActions from "@app/components/CommentActions.svelte"
|
|
|
|
|
import EventReply from "@app/components/EventReply.svelte"
|
2026-07-28 16:16:26 +00:00
|
|
|
import {network, reader} from "@app/core"
|
|
|
|
|
import {deriveEvent, deriveEventsById} from "@app/repository"
|
2026-06-08 22:33:38 +00:00
|
|
|
import {decodeRelay} from "@app/relays"
|
2025-07-07 22:28:36 +00:00
|
|
|
|
2025-10-13 20:35:02 +00:00
|
|
|
const {relay, id} = $page.params as MakeNonOptional<typeof $page.params>
|
2025-07-07 22:28:36 +00:00
|
|
|
const url = decodeRelay(relay)
|
2025-11-20 23:54:06 +00:00
|
|
|
const event = deriveEvent(id, [url])
|
2025-07-07 22:28:36 +00:00
|
|
|
const filters = [{kinds: [COMMENT], "#E": [id]}]
|
2026-07-28 16:16:26 +00:00
|
|
|
const replies = deriveEventsAsc(deriveEventsById(filters))
|
|
|
|
|
const goal = derived(event, $event => ($event ? reader(ZapGoal)($event) : undefined))
|
|
|
|
|
const summary = $derived($goal?.summary() ?? "")
|
2025-07-07 22:28:36 +00:00
|
|
|
|
|
|
|
|
const back = () => history.back()
|
|
|
|
|
|
|
|
|
|
const openReply = () => {
|
|
|
|
|
showReply = true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const closeReply = () => {
|
|
|
|
|
showReply = false
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const expand = () => {
|
|
|
|
|
showAll = true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let showAll = $state(false)
|
|
|
|
|
let showReply = $state(false)
|
|
|
|
|
|
|
|
|
|
onMount(() => {
|
|
|
|
|
const controller = new AbortController()
|
|
|
|
|
|
2026-07-28 16:16:26 +00:00
|
|
|
$network.request({relays: [url], filters, signal: controller.signal})
|
2025-07-07 22:28:36 +00:00
|
|
|
|
|
|
|
|
return () => {
|
|
|
|
|
controller.abort()
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
</script>
|
|
|
|
|
|
2026-03-12 23:41:07 +00:00
|
|
|
<SpaceBar {back}>
|
2025-07-07 22:28:36 +00:00
|
|
|
{#snippet title()}
|
2025-11-20 23:54:06 +00:00
|
|
|
<h1 class="text-xl">{$event?.content}</h1>
|
2025-07-07 22:28:36 +00:00
|
|
|
{/snippet}
|
2026-03-12 23:41:07 +00:00
|
|
|
</SpaceBar>
|
2025-07-07 22:28:36 +00:00
|
|
|
|
2026-06-22 20:36:57 +00:00
|
|
|
<PageContent class="flex flex-col gap-2 p-2 sm:gap-4 sm:p-4">
|
2025-07-07 22:28:36 +00:00
|
|
|
{#if $event}
|
|
|
|
|
<div class="flex flex-col gap-3">
|
2026-06-24 20:56:53 +00:00
|
|
|
<NoteCard event={$event} {url} class="card z-feature w-full">
|
|
|
|
|
<div class="flex flex-col gap-3 ml-12">
|
2026-02-03 22:18:58 +00:00
|
|
|
<NoteContent showEntire event={{...$event, content: summary}} {url} />
|
2025-10-06 18:23:19 +00:00
|
|
|
<GoalActions showRoom event={$event} {url} />
|
2025-07-07 22:28:36 +00:00
|
|
|
</div>
|
|
|
|
|
</NoteCard>
|
|
|
|
|
{#if !showAll && $replies.length > 4}
|
|
|
|
|
<div class="flex justify-center">
|
2026-06-24 20:56:53 +00:00
|
|
|
<Button class="button button-link" onclick={expand}>
|
2025-09-10 22:26:39 +00:00
|
|
|
<Icon icon={SortVertical} />
|
2025-07-07 22:28:36 +00:00
|
|
|
Show all {$replies.length} replies
|
|
|
|
|
</Button>
|
|
|
|
|
</div>
|
|
|
|
|
{/if}
|
2025-11-20 23:12:16 +00:00
|
|
|
{#each $replies.slice(0, showAll ? undefined : 4) as reply (reply.id)}
|
2026-06-24 20:56:53 +00:00
|
|
|
<NoteCard event={reply} {url} class="card z-feature w-full">
|
|
|
|
|
<div class="flex flex-col gap-3 ml-12">
|
2026-02-03 22:18:58 +00:00
|
|
|
<NoteContent showEntire event={reply} {url} />
|
2026-02-03 19:00:13 +00:00
|
|
|
<CommentActions segment="goals" event={reply} {url} />
|
2025-07-07 22:28:36 +00:00
|
|
|
</div>
|
|
|
|
|
</NoteCard>
|
|
|
|
|
{/each}
|
|
|
|
|
</div>
|
|
|
|
|
{#if showReply}
|
|
|
|
|
<EventReply {url} event={$event} onClose={closeReply} onSubmit={closeReply} />
|
|
|
|
|
{:else}
|
2026-06-04 21:31:07 +00:00
|
|
|
<div class="flex justify-end">
|
2026-06-24 20:56:53 +00:00
|
|
|
<Button class="button button-primary" onclick={openReply}>
|
2025-09-10 22:26:39 +00:00
|
|
|
<Icon icon={Reply} />
|
2025-07-07 22:28:36 +00:00
|
|
|
Comment on this goal
|
|
|
|
|
</Button>
|
|
|
|
|
</div>
|
|
|
|
|
{/if}
|
|
|
|
|
{:else}
|
2026-06-04 21:31:07 +00:00
|
|
|
<div class="flex justify-center py-20">
|
|
|
|
|
{#await sleep(5000)}
|
|
|
|
|
<Spinner loading>Loading funding goal...</Spinner>
|
|
|
|
|
{:then}
|
|
|
|
|
<p>Failed to load funding goal.</p>
|
|
|
|
|
{/await}
|
|
|
|
|
</div>
|
2025-07-07 22:28:36 +00:00
|
|
|
{/if}
|
|
|
|
|
</PageContent>
|