2024-10-24 22:48:45 +00:00
|
|
|
<script lang="ts">
|
|
|
|
|
import type {NativeEmoji} from "emoji-picker-element/shared"
|
2025-02-18 01:33:21 +00:00
|
|
|
import type {TrustedEvent} from "@welshman/util"
|
2024-10-24 22:48:45 +00:00
|
|
|
import {pubkey} from "@welshman/app"
|
|
|
|
|
import Button from "@lib/components/Button.svelte"
|
|
|
|
|
import Icon from "@lib/components/Icon.svelte"
|
|
|
|
|
import EmojiPicker from "@lib/components/EmojiPicker.svelte"
|
2025-07-17 22:29:26 +00:00
|
|
|
import ZapButton from "@app/components/ZapButton.svelte"
|
2024-10-24 22:48:45 +00:00
|
|
|
import EventInfo from "@app/components/EventInfo.svelte"
|
2025-02-18 17:03:10 +00:00
|
|
|
import EventDeleteConfirm from "@app/components/EventDeleteConfirm.svelte"
|
2025-08-21 22:01:31 +00:00
|
|
|
import {ENABLE_ZAPS} from "@app/core/state"
|
|
|
|
|
import {publishReaction, canEnforceNip70} from "@app/core/commands"
|
|
|
|
|
import {pushModal} from "@app/util/modal"
|
2025-09-10 22:26:39 +00:00
|
|
|
import SmileCircle from "@assets/icons/smile-circle.svg?dataurl"
|
|
|
|
|
import Bolt from "@assets/icons/bolt.svg?dataurl"
|
|
|
|
|
import Reply from "@assets/icons/reply-2.svg?dataurl"
|
|
|
|
|
import Code2 from "@assets/icons/code-2.svg?dataurl"
|
|
|
|
|
import TrashBin2 from "@assets/icons/trash-bin-2.svg?dataurl"
|
2024-10-24 22:48:45 +00:00
|
|
|
|
2025-02-19 01:15:41 +00:00
|
|
|
type Props = {
|
|
|
|
|
url: string
|
|
|
|
|
event: TrustedEvent
|
|
|
|
|
reply: () => void
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const {url, event, reply}: Props = $props()
|
2024-10-24 22:48:45 +00:00
|
|
|
|
2025-08-19 21:03:04 +00:00
|
|
|
const shouldProtect = canEnforceNip70(url)
|
|
|
|
|
|
2025-07-30 23:30:03 +00:00
|
|
|
const onEmoji = (async (event: TrustedEvent, url: string, emoji: NativeEmoji) => {
|
2024-10-24 22:48:45 +00:00
|
|
|
history.back()
|
2025-07-30 23:30:03 +00:00
|
|
|
publishReaction({
|
|
|
|
|
event,
|
|
|
|
|
relays: [url],
|
|
|
|
|
content: emoji.unicode,
|
2025-08-19 21:03:04 +00:00
|
|
|
protect: await shouldProtect,
|
2025-07-30 23:30:03 +00:00
|
|
|
})
|
2025-02-19 01:15:41 +00:00
|
|
|
}).bind(undefined, event, url)
|
2024-10-24 22:48:45 +00:00
|
|
|
|
|
|
|
|
const showEmojiPicker = () => pushModal(EmojiPicker, {onClick: onEmoji}, {replaceState: true})
|
|
|
|
|
|
2025-01-28 17:47:11 +00:00
|
|
|
const sendReply = () => {
|
|
|
|
|
history.back()
|
|
|
|
|
reply()
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-03 20:10:47 +00:00
|
|
|
const showInfo = () => pushModal(EventInfo, {url, event}, {replaceState: true})
|
2024-10-24 22:48:45 +00:00
|
|
|
|
2025-02-18 17:03:10 +00:00
|
|
|
const showDelete = () => pushModal(EventDeleteConfirm, {url, event})
|
2024-10-24 22:48:45 +00:00
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<div class="col-2">
|
2025-02-04 01:21:46 +00:00
|
|
|
<Button class="btn btn-primary w-full" onclick={showEmojiPicker}>
|
2025-09-10 22:26:39 +00:00
|
|
|
<Icon size={4} icon={SmileCircle} />
|
2024-10-24 22:48:45 +00:00
|
|
|
Send Reaction
|
|
|
|
|
</Button>
|
2025-07-17 22:29:26 +00:00
|
|
|
{#if ENABLE_ZAPS}
|
|
|
|
|
<ZapButton replaceState {url} {event} class="btn btn-secondary w-full">
|
2025-09-10 22:26:39 +00:00
|
|
|
<Icon size={4} icon={Bolt} />
|
2025-07-17 22:29:26 +00:00
|
|
|
Send Zap
|
|
|
|
|
</ZapButton>
|
|
|
|
|
{/if}
|
2025-02-04 01:21:46 +00:00
|
|
|
<Button class="btn btn-neutral w-full" onclick={sendReply}>
|
2025-09-10 22:26:39 +00:00
|
|
|
<Icon size={4} icon={Reply} />
|
2025-01-28 17:47:11 +00:00
|
|
|
Send Reply
|
|
|
|
|
</Button>
|
2025-02-04 01:21:46 +00:00
|
|
|
<Button class="btn btn-neutral" onclick={showInfo}>
|
2025-09-10 22:26:39 +00:00
|
|
|
<Icon size={4} icon={Code2} />
|
2024-10-24 22:48:45 +00:00
|
|
|
Message Details
|
|
|
|
|
</Button>
|
|
|
|
|
{#if event.pubkey === $pubkey}
|
2025-02-04 01:21:46 +00:00
|
|
|
<Button class="btn btn-neutral text-error" onclick={showDelete}>
|
2025-09-10 22:26:39 +00:00
|
|
|
<Icon size={4} icon={TrashBin2} />
|
2024-10-24 22:48:45 +00:00
|
|
|
Delete Message
|
|
|
|
|
</Button>
|
|
|
|
|
{/if}
|
|
|
|
|
</div>
|