flotilla/src/app/components/ChannelMessageMenuMobile.svelte

58 lines
1.8 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"
import EventInfo from "@app/components/EventInfo.svelte"
import EventDeleteConfirm from "@app/components/EventDeleteConfirm.svelte"
2024-10-24 22:48:45 +00:00
import {publishReaction} 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
2025-02-18 01:33:21 +00:00
const onEmoji = ((event: TrustedEvent, url: string, emoji: NativeEmoji) => {
2024-10-24 22:48:45 +00:00
history.back()
publishReaction({event, relays: [url], content: emoji.unicode})
}).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>
<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>