flotilla/src/app/components/NoteCard.svelte

56 lines
1.7 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"
2024-10-08 18:39:16 +00:00
import {nip19} from "nostr-tools"
2024-10-01 23:27:25 +00:00
import {ctx} from "@welshman/lib"
2024-10-17 22:58:18 +00:00
import {getListTags, getPubkeyTagValues} from "@welshman/util"
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
export let event
2024-11-21 22:14:46 +00:00
export let minimal = false
2024-10-09 19:45:13 +00:00
export let hideProfile = false
2024-10-01 23:27:25 +00:00
const relays = ctx.app.router.Event(event).getUrls()
const nevent = nip19.neventEncode({id: event.id, relays})
2024-10-17 22:58:18 +00:00
const ignoreMute = () => {
muted = false
}
let muted = getPubkeyTagValues(getListTags($userMutes)).includes(event.pubkey)
2024-09-24 21:12:38 +00:00
</script>
<div class="flex flex-col gap-2 {$$props.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" on:click={ignoreMute}>Show anyway</Button>
</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>
<slot />
{/if}
2024-09-24 21:12:38 +00:00
</div>