flotilla/src/app/components/ThunkStatusOrDeleted.svelte

33 lines
963 B
Svelte
Raw Normal View History

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
// 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
const thunk = $derived($thunks.merge($history.filter(t => t.event.id === event.id)))
2025-02-06 17:39:23 +00:00
</script>
{#if $deleted}
<div class="button button-error button-xs rounded-full">Deleted</div>
2026-08-21 15:31:53 +00:00
{:else}
{#if thunk.thunks.length > 0 && !thunk.hasStatus(PublishStatus.Success)}
<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}