flotilla/src/app/components/ChannelMessageMenuMobile.svelte

73 lines
2.2 KiB
Svelte
Raw Normal View History

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"
import EventDeleteConfirm from "@app/components/EventDeleteConfirm.svelte"
2025-07-17 22:29:26 +00:00
import {ENABLE_ZAPS} from "@app/state"
import {publishReaction, canEnforceNip70} from "@app/commands"
import {pushModal} from "@app/modal"
2024-10-24 22:48:45 +00:00
type Props = {
url: string
event: TrustedEvent
reply: () => void
}
const {url, event, reply}: Props = $props()
2024-10-24 22:48:45 +00:00
const shouldProtect = canEnforceNip70(url)
const onEmoji = (async (event: TrustedEvent, url: string, emoji: NativeEmoji) => {
2024-10-24 22:48:45 +00:00
history.back()
publishReaction({
event,
relays: [url],
content: emoji.unicode,
protect: await shouldProtect,
})
}).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()
}
const showInfo = () => pushModal(EventInfo, {url, event}, {replaceState: true})
2024-10-24 22:48:45 +00:00
const showDelete = () => pushModal(EventDeleteConfirm, {url, event})
2024-10-24 22:48:45 +00:00
</script>
<div class="col-2">
<Button class="btn btn-primary w-full" onclick={showEmojiPicker}>
2024-10-24 22:48:45 +00:00
<Icon size={4} icon="smile-circle" />
Send Reaction
</Button>
2025-07-17 22:29:26 +00:00
{#if ENABLE_ZAPS}
<ZapButton replaceState {url} {event} class="btn btn-secondary w-full">
<Icon size={4} icon="bolt" />
Send Zap
</ZapButton>
{/if}
<Button class="btn btn-neutral w-full" onclick={sendReply}>
2025-01-28 17:47:11 +00:00
<Icon size={4} icon="reply" />
Send Reply
</Button>
<Button class="btn btn-neutral" onclick={showInfo}>
2024-10-24 22:48:45 +00:00
<Icon size={4} icon="code-2" />
Message Details
</Button>
{#if event.pubkey === $pubkey}
<Button class="btn btn-neutral text-error" onclick={showDelete}>
2024-10-24 22:48:45 +00:00
<Icon size={4} icon="trash-bin-2" />
Delete Message
</Button>
{/if}
</div>