2025-02-06 17:39:23 +00:00
|
|
|
<script lang="ts">
|
2026-02-04 01:09:30 +00:00
|
|
|
import type {Snippet} from "svelte"
|
2025-02-06 17:39:23 +00:00
|
|
|
import type {TrustedEvent} from "@welshman/util"
|
2026-02-04 01:09:30 +00:00
|
|
|
import {PublishStatus} from "@welshman/net"
|
2026-07-28 16:16:26 +00:00
|
|
|
import {deriveIsDeleted} from "@app/repository"
|
2025-02-06 17:39:23 +00:00
|
|
|
import ThunkStatus from "@app/components/ThunkStatus.svelte"
|
2026-07-28 16:16:26 +00:00
|
|
|
import {thunks} from "@app/core"
|
2025-02-06 17:39:23 +00:00
|
|
|
|
2026-02-04 01:09:30 +00:00
|
|
|
type Props = {
|
|
|
|
|
event: TrustedEvent
|
2026-08-21 15:31:53 +00:00
|
|
|
status?: Snippet
|
2026-02-04 01:09:30 +00:00
|
|
|
children?: Snippet
|
|
|
|
|
}
|
|
|
|
|
|
2026-08-21 15:31:53 +00:00
|
|
|
const {event, status, children}: Props = $props()
|
2025-02-06 17:39:23 +00:00
|
|
|
|
2026-08-22 18:40:05 +00:00
|
|
|
// Editing a replaceable event hands this a different event
|
|
|
|
|
const deleted = $derived(deriveIsDeleted(event))
|
2026-07-28 16:16:26 +00:00
|
|
|
const history = $thunks.history
|
2026-08-22 20:12:11 +00:00
|
|
|
// Subscribed rather than read: a thunk mutates its results in place and notifies, so reading
|
|
|
|
|
// them off the object would leave this showing a publish that has since finished.
|
2026-07-28 16:16:26 +00:00
|
|
|
const thunk = $derived($thunks.merge($history.filter(t => t.event.id === event.id)))
|
2025-02-06 17:39:23 +00:00
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
{#if $deleted}
|
2026-06-24 20:56:53 +00:00
|
|
|
<div class="button button-error button-xs rounded-full">Deleted</div>
|
2026-08-21 15:31:53 +00:00
|
|
|
{:else}
|
2026-08-22 20:12:11 +00:00
|
|
|
{#if $thunk.thunks.length > 0 && !$thunk.hasStatus(PublishStatus.Success)}
|
2026-08-21 15:31:53 +00:00
|
|
|
<ThunkStatus {thunk} />
|
|
|
|
|
{:else}
|
|
|
|
|
{@render status?.()}
|
|
|
|
|
{/if}
|
2026-02-04 01:09:30 +00:00
|
|
|
{@render children?.()}
|
2025-02-06 17:39:23 +00:00
|
|
|
{/if}
|