flotilla/src/app/components/CalendarEventActions.svelte

56 lines
1.8 KiB
Svelte
Raw Normal View History

2025-02-06 17:29:30 +00:00
<script lang="ts">
2025-05-12 22:10:24 +00:00
import type {TrustedEvent, EventContent} from "@welshman/util"
2025-02-06 17:53:50 +00:00
import {pubkey} from "@welshman/app"
2025-03-18 22:36:52 +00:00
import Icon from "@lib/components/Icon.svelte"
import Button from "@lib/components/Button.svelte"
2025-02-06 17:29:30 +00:00
import ReactionSummary from "@app/components/ReactionSummary.svelte"
2025-02-06 17:39:23 +00:00
import ThunkStatusOrDeleted from "@app/components/ThunkStatusOrDeleted.svelte"
2025-02-06 17:53:50 +00:00
import EventActivity from "@app/components/EventActivity.svelte"
2025-02-06 18:00:25 +00:00
import EventActions from "@app/components/EventActions.svelte"
2025-03-18 22:36:52 +00:00
import CalendarEventEdit from "@app/components/CalendarEventEdit.svelte"
2025-02-06 17:29:30 +00:00
import {publishDelete, publishReaction} from "@app/commands"
import {makeCalendarPath} from "@app/routes"
2025-03-18 22:36:52 +00:00
import {pushModal} from "@app/modal"
2025-02-06 17:29:30 +00:00
2025-02-06 17:53:50 +00:00
const {
url,
event,
showActivity = false,
}: {
url: string
event: TrustedEvent
2025-02-06 17:29:30 +00:00
showActivity?: boolean
2025-02-06 17:53:50 +00:00
} = $props()
2025-02-06 17:29:30 +00:00
const path = makeCalendarPath(url, event.id)
2025-03-18 22:36:52 +00:00
const editEvent = () => pushModal(CalendarEventEdit, {url, event})
2025-05-12 22:10:24 +00:00
const deleteReaction = (event: TrustedEvent) => publishDelete({relays: [url], event})
2025-02-06 17:29:30 +00:00
2025-05-12 22:10:24 +00:00
const createReaction = (template: EventContent) =>
publishReaction({...template, event, relays: [url]})
2025-02-06 17:29:30 +00:00
</script>
<div class="flex flex-wrap items-center justify-between gap-2">
<div class="flex flex-grow flex-wrap justify-end gap-2">
2025-05-12 22:10:24 +00:00
<ReactionSummary {url} {event} {deleteReaction} {createReaction} reactionClass="tooltip-left" />
2025-02-06 17:39:23 +00:00
<ThunkStatusOrDeleted {event} />
2025-02-06 17:29:30 +00:00
{#if showActivity}
2025-02-06 17:53:50 +00:00
<EventActivity {url} {path} {event} />
2025-02-06 17:29:30 +00:00
{/if}
2025-03-18 22:36:52 +00:00
<EventActions {url} {event} noun="Event">
{#snippet customActions()}
{#if event.pubkey === $pubkey}
<li>
<Button onclick={editEvent}>
<Icon size={4} icon="pen" />
Edit Event
</Button>
</li>
{/if}
{/snippet}
</EventActions>
2025-02-06 17:29:30 +00:00
</div>
</div>