flotilla/src/app/components/NoteCard.svelte

67 lines
1.9 KiB
Svelte
Raw Normal View History

2024-09-24 21:12:38 +00:00
<script lang="ts">
2024-11-21 22:14:46 +00:00
import cx from "classnames"
import type {Snippet} from "svelte"
2025-04-09 22:32:18 +00:00
import * as nip19 from "nostr-tools/nip19"
2024-10-17 22:58:18 +00:00
import {getListTags, getPubkeyTagValues} from "@welshman/util"
import type {TrustedEvent} from "@welshman/util"
2025-04-09 22:32:18 +00:00
import {formatTimestamp, Router, userMutes} from "@welshman/app"
2024-10-01 23:27:25 +00:00
import Link from "@lib/components/Link.svelte"
2024-10-17 22:58:18 +00:00
import Icon from "@lib/components/Icon.svelte"
import Button from "@lib/components/Button.svelte"
2024-09-24 21:12:38 +00:00
import Profile from "@app/components/Profile.svelte"
2024-11-21 22:14:46 +00:00
import ProfileName from "@app/components/ProfileName.svelte"
2024-10-08 18:39:16 +00:00
import {entityLink} from "@app/state"
2024-09-24 21:12:38 +00:00
const {
event,
children,
minimal = false,
hideProfile = false,
...restProps
}: {
2025-02-04 00:37:14 +00:00
event: TrustedEvent
children: Snippet
minimal?: boolean
hideProfile?: boolean
class?: string
} = $props()
2024-10-01 23:27:25 +00:00
2025-04-09 22:32:18 +00:00
const relays = Router.get().Event(event).getUrls()
2024-10-01 23:27:25 +00:00
const nevent = nip19.neventEncode({id: event.id, relays})
2024-10-17 22:58:18 +00:00
const ignoreMute = () => {
muted = false
}
let muted = $state(getPubkeyTagValues(getListTags($userMutes)).includes(event.pubkey))
2024-09-24 21:12:38 +00:00
</script>
2025-02-04 00:37:14 +00:00
<div class="flex flex-col gap-2 {restProps.class}">
2024-10-17 22:58:18 +00:00
{#if muted}
2024-10-17 23:03:50 +00:00
<div class="flex items-center justify-between">
2024-10-17 22:58:18 +00:00
<div class="row-2 relative">
<Icon icon="danger" class="mt-1" />
2024-10-17 23:03:50 +00:00
<p>You have muted this person.</p>
2024-10-17 22:58:18 +00:00
</div>
<Button class="link ml-8" onclick={ignoreMute}>Show anyway</Button>
2024-10-17 22:58:18 +00:00
</div>
{:else}
<div class="flex justify-between gap-2">
{#if !hideProfile}
2024-11-21 22:14:46 +00:00
{#if minimal}
@<ProfileName pubkey={event.pubkey} />
{:else}
<Profile pubkey={event.pubkey} />
{/if}
2024-10-17 22:58:18 +00:00
{/if}
2024-11-21 22:14:46 +00:00
<Link
external
href={entityLink(nevent)}
class={cx("text-sm opacity-75", {"text-xs": minimal})}>
2024-10-17 22:58:18 +00:00
{formatTimestamp(event.created_at)}
</Link>
</div>
2025-02-04 00:37:14 +00:00
{@render children()}
2024-10-17 22:58:18 +00:00
{/if}
2024-09-24 21:12:38 +00:00
</div>