2025-02-06 17:29:30 +00:00
|
|
|
<script lang="ts">
|
2026-08-29 16:19:01 +00:00
|
|
|
import {onDestroy} from "svelte"
|
2026-07-28 16:16:26 +00:00
|
|
|
import {derived} from "svelte/store"
|
2025-02-06 17:29:30 +00:00
|
|
|
import {page} from "$app/stores"
|
2025-02-12 00:00:14 +00:00
|
|
|
import {sortBy, sleep} from "@welshman/lib"
|
2025-10-13 20:35:02 +00:00
|
|
|
import type {MakeNonOptional} from "@welshman/lib"
|
2026-08-17 15:42:14 +00:00
|
|
|
import {getCommentFiltersForRoot} from "@welshman/util"
|
2026-07-28 16:16:26 +00:00
|
|
|
import {TimeEvent} 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-02-06 17:29:30 +00:00
|
|
|
import Icon from "@lib/components/Icon.svelte"
|
2025-03-19 17:30:36 +00:00
|
|
|
import PageContent from "@lib/components/PageContent.svelte"
|
2025-02-06 17:29:30 +00:00
|
|
|
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-06 17:15:03 +00:00
|
|
|
import Content from "@app/components/Content.svelte"
|
2026-02-03 22:18:58 +00:00
|
|
|
import NoteContent from "@app/components/NoteContent.svelte"
|
2025-02-06 17:29:30 +00:00
|
|
|
import NoteCard from "@app/components/NoteCard.svelte"
|
2025-02-06 18:24:31 +00:00
|
|
|
import CalendarEventActions from "@app/components/CalendarEventActions.svelte"
|
2026-08-21 15:31:53 +00:00
|
|
|
import CommentActions from "@app/components/CommentActions.svelte"
|
2025-02-12 00:00:14 +00:00
|
|
|
import CalendarEventHeader from "@app/components/CalendarEventHeader.svelte"
|
|
|
|
|
import CalendarEventMeta from "@app/components/CalendarEventMeta.svelte"
|
|
|
|
|
import CalendarEventDate from "@app/components/CalendarEventDate.svelte"
|
2025-02-06 18:24:31 +00:00
|
|
|
import EventReply from "@app/components/EventReply.svelte"
|
2026-07-28 16:16:26 +00:00
|
|
|
import {network, reader} from "@app/core"
|
|
|
|
|
import {deriveEvent, deriveEvents} from "@app/repository"
|
2026-08-29 16:19:01 +00:00
|
|
|
import {makeFeedContext} from "@app/feeds"
|
2026-06-08 22:33:38 +00:00
|
|
|
import {decodeRelay} from "@app/relays"
|
2025-02-06 17:29:30 +00:00
|
|
|
|
2026-02-06 17:15:03 +00:00
|
|
|
const {relay, address} = $page.params as MakeNonOptional<typeof $page.params>
|
2025-02-06 17:29:30 +00:00
|
|
|
const url = decodeRelay(relay)
|
2026-08-29 16:19:01 +00:00
|
|
|
const context = makeFeedContext({relays: [url]})
|
2026-02-06 17:15:03 +00:00
|
|
|
const event = deriveEvent(address, [url])
|
2026-07-28 16:16:26 +00:00
|
|
|
const timeEvent = derived(event, $event => ($event ? reader(TimeEvent)($event) : undefined))
|
2026-08-17 15:42:14 +00:00
|
|
|
const filters = $derived($event ? getCommentFiltersForRoot([$event]) : [])
|
|
|
|
|
const replies = $derived(deriveEvents(filters))
|
2025-02-06 17:29:30 +00:00
|
|
|
|
|
|
|
|
const back = () => history.back()
|
|
|
|
|
|
|
|
|
|
const openReply = () => {
|
|
|
|
|
showReply = true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const closeReply = () => {
|
|
|
|
|
showReply = false
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const expand = () => {
|
|
|
|
|
showAll = true
|
|
|
|
|
}
|
|
|
|
|
|
2026-08-29 16:19:01 +00:00
|
|
|
onDestroy(context.cleanup)
|
|
|
|
|
|
2025-02-06 17:29:30 +00:00
|
|
|
let showAll = $state(false)
|
|
|
|
|
let showReply = $state(false)
|
|
|
|
|
|
2026-08-17 15:42:14 +00:00
|
|
|
$effect(() => {
|
|
|
|
|
if (filters.length > 0) {
|
|
|
|
|
const controller = new AbortController()
|
2025-04-11 16:27:19 +00:00
|
|
|
|
2026-08-17 15:42:14 +00:00
|
|
|
$network.request({relays: [url], filters, signal: controller.signal})
|
2025-02-06 17:29:30 +00:00
|
|
|
|
2026-08-17 15:42:14 +00:00
|
|
|
return () => controller.abort()
|
2025-02-06 17:29:30 +00:00
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
</script>
|
|
|
|
|
|
2026-03-12 23:41:07 +00:00
|
|
|
<SpaceBar {back}>
|
2025-03-19 17:30:36 +00:00
|
|
|
{#snippet title()}
|
2026-07-28 16:16:26 +00:00
|
|
|
<h1 class="text-xl">{$timeEvent?.title() ?? ""}</h1>
|
2025-03-19 17:30:36 +00:00
|
|
|
{/snippet}
|
2026-03-12 23:41:07 +00:00
|
|
|
</SpaceBar>
|
2025-03-19 17:30: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-02-06 17:29:30 +00:00
|
|
|
{#if $event}
|
2026-06-24 20:56:53 +00:00
|
|
|
<div class="card flex flex-col gap-3 z-feature">
|
2025-02-06 19:12:15 +00:00
|
|
|
<div class="flex items-start gap-4">
|
2025-02-12 00:00:14 +00:00
|
|
|
<CalendarEventDate event={$event} />
|
2026-04-07 21:53:19 +00:00
|
|
|
<div class="flex min-w-0 grow flex-col gap-1">
|
2025-03-17 16:53:14 +00:00
|
|
|
<CalendarEventHeader event={$event} />
|
2025-04-15 18:03:27 +00:00
|
|
|
<CalendarEventMeta event={$event} {url} />
|
2025-02-06 19:12:15 +00:00
|
|
|
<div class="flex py-2 opacity-50">
|
2026-06-24 20:56:53 +00:00
|
|
|
<div class="h-px grow opacity-25" style="background-color: var(--line)"></div>
|
2025-02-06 19:12:15 +00:00
|
|
|
</div>
|
2026-02-06 17:15:03 +00:00
|
|
|
<Content showEntire event={$event} {url} />
|
2025-02-06 19:12:15 +00:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="flex w-full flex-col justify-end sm:flex-row">
|
2026-08-29 16:19:01 +00:00
|
|
|
<CalendarEventActions showRoom {url} event={$event} {context} />
|
2025-02-06 17:29:30 +00:00
|
|
|
</div>
|
2025-02-06 19:12:15 +00:00
|
|
|
</div>
|
2025-03-19 17:30:36 +00:00
|
|
|
{#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-03-19 17:30:36 +00:00
|
|
|
Show all {$replies.length} replies
|
|
|
|
|
</Button>
|
|
|
|
|
</div>
|
|
|
|
|
{/if}
|
|
|
|
|
{#each sortBy(e => e.created_at, $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-08-29 16:19:01 +00:00
|
|
|
<CommentActions segment="calendar" event={reply} {url} {context} />
|
2025-03-19 17:30:36 +00:00
|
|
|
</div>
|
|
|
|
|
</NoteCard>
|
|
|
|
|
{/each}
|
|
|
|
|
{#if showReply}
|
|
|
|
|
<EventReply {url} event={$event} onClose={closeReply} onSubmit={closeReply} />
|
|
|
|
|
{:else}
|
|
|
|
|
<div class="flex justify-end px-2 pb-2">
|
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-03-19 17:30:36 +00:00
|
|
|
Leave comment
|
|
|
|
|
</Button>
|
|
|
|
|
</div>
|
|
|
|
|
{/if}
|
2025-02-06 17:29:30 +00:00
|
|
|
{:else}
|
2026-06-04 21:31:07 +00:00
|
|
|
<div class="flex justify-center py-20">
|
|
|
|
|
{#await sleep(5000)}
|
|
|
|
|
<Spinner loading>Loading event...</Spinner>
|
|
|
|
|
{:then}
|
|
|
|
|
<p>Failed to load event.</p>
|
|
|
|
|
{/await}
|
|
|
|
|
</div>
|
2025-02-06 17:29:30 +00:00
|
|
|
{/if}
|
2025-03-19 17:30:36 +00:00
|
|
|
</PageContent>
|