flotilla/src/app/components/ThunkStatusOrDeleted.svelte

33 lines
994 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"
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"
2026-08-31 17:03:01 +00:00
import type {FeedContext} from "@app/feeds"
import {noThunks, thunksByEventId} from "@app/thunks"
2025-02-06 17:39:23 +00:00
2026-02-04 01:09:30 +00:00
type Props = {
event: TrustedEvent
2026-08-31 17:03:01 +00:00
context: FeedContext
2026-08-21 15:31:53 +00:00
status?: Snippet
2026-02-04 01:09:30 +00:00
children?: Snippet
}
2026-08-31 17:03:01 +00:00
const {event, context, status, children}: Props = $props()
const deleted = $derived(context.deleted(event))
const pending = $derived($thunksByEventId.get(event.id) ?? noThunks)
const thunk = $derived($thunks.merge(pending))
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}
2026-08-22 20:12:11 +00:00
{#if $thunk.thunks.length > 0 && !$thunk.hasStatus(PublishStatus.Success)}
<ThunkStatus {thunk} inline />
2026-08-21 15:31:53 +00:00
{:else}
{@render status?.()}
{/if}
2026-02-04 01:09:30 +00:00
{@render children?.()}
2025-02-06 17:39:23 +00:00
{/if}