Files
flotilla/src/app/components/NoteCard.svelte
T
2026-03-09 21:12:09 -07:00

65 lines
1.8 KiB
Svelte

<script lang="ts">
import cx from "classnames"
import type {Snippet} from "svelte"
import {formatTimestamp} from "@welshman/lib"
import {getListTags, getPubkeyTagValues} from "@welshman/util"
import type {TrustedEvent} from "@welshman/util"
import Danger from "@assets/icons/danger-triangle.svg?dataurl"
import Icon from "@lib/components/Icon.svelte"
import Button from "@lib/components/Button.svelte"
import Profile from "@app/components/Profile.svelte"
import ProfileName from "@app/components/ProfileName.svelte"
import {goToEvent} from "@app/util/routes"
import {isEventMuted} from "@app/core/state"
const {
event,
children,
minimal = false,
hideProfile = false,
url,
...restProps
}: {
event: TrustedEvent
children: Snippet
minimal?: boolean
hideProfile?: boolean
url?: string
class?: string
} = $props()
const ignoreMute = () => {
muted = false
}
let muted = $state($isEventMuted(event))
</script>
<div class="flex flex-col gap-2 shadow-md {restProps.class}">
{#if muted}
<div class="flex items-center justify-between">
<div class="row-2 relative">
<Icon icon={Danger} class="mt-1" />
<p>You have muted this person.</p>
</div>
<Button class="link ml-8" onclick={ignoreMute}>Show anyway</Button>
</div>
{:else}
<div class="flex items-start justify-between gap-2">
{#if !hideProfile}
{#if minimal}
@<ProfileName pubkey={event.pubkey} {url} />
{:else}
<Profile pubkey={event.pubkey} {url} />
{/if}
{/if}
<Button
class={cx("text-sm opacity-75", {"text-xs": minimal})}
onclick={() => goToEvent(event)}>
{formatTimestamp(event.created_at)}
</Button>
</div>
{@render children()}
{/if}
</div>