2024-09-24 21:12:38 +00:00
|
|
|
<script lang="ts">
|
2024-11-21 22:14:46 +00:00
|
|
|
import cx from "classnames"
|
2025-02-04 01:21:46 +00:00
|
|
|
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"
|
2025-02-04 01:21:46 +00:00
|
|
|
import type {TrustedEvent} from "@welshman/util"
|
2025-04-24 17:02:27 +00:00
|
|
|
import {Router} from "@welshman/router"
|
|
|
|
|
import {formatTimestamp, 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
|
|
|
|
2025-02-04 01:21:46 +00:00
|
|
|
const {
|
|
|
|
|
event,
|
|
|
|
|
children,
|
|
|
|
|
minimal = false,
|
|
|
|
|
hideProfile = false,
|
2025-04-15 18:03:27 +00:00
|
|
|
url,
|
2025-02-04 01:21:46 +00:00
|
|
|
...restProps
|
|
|
|
|
}: {
|
2025-02-04 00:37:14 +00:00
|
|
|
event: TrustedEvent
|
2025-02-04 01:21:46 +00:00
|
|
|
children: Snippet
|
|
|
|
|
minimal?: boolean
|
|
|
|
|
hideProfile?: boolean
|
2025-04-15 18:03:27 +00:00
|
|
|
url?: string
|
2025-02-04 01:21:46 +00:00
|
|
|
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
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-04 01:21:46 +00:00
|
|
|
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>
|
2025-02-04 01:21:46 +00:00
|
|
|
<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}
|
2025-04-15 18:03:27 +00:00
|
|
|
@<ProfileName pubkey={event.pubkey} {url} />
|
2024-11-21 22:14:46 +00:00
|
|
|
{:else}
|
2025-04-15 18:03:27 +00:00
|
|
|
<Profile pubkey={event.pubkey} {url} />
|
2024-11-21 22:14:46 +00:00
|
|
|
{/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>
|