flotilla/src/app/components/ChatMessageMenuMobile.svelte

84 lines
2.5 KiB
Svelte
Raw Normal View History

2024-10-24 23:28:56 +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"
2026-02-09 16:49:55 +00:00
import SmileCircle from "@assets/icons/smile-circle.svg?dataurl"
2026-03-10 22:13:33 +00:00
import Pen from "@assets/icons/pen.svg?dataurl"
2026-02-09 16:49:55 +00:00
import Reply from "@assets/icons/reply-2.svg?dataurl"
import Copy from "@assets/icons/copy.svg?dataurl"
import Code2 from "@assets/icons/code-2.svg?dataurl"
2024-10-24 23:28:56 +00:00
import Icon from "@lib/components/Icon.svelte"
2026-02-09 16:49:55 +00:00
import Modal from "@lib/components/Modal.svelte"
import ModalBody from "@lib/components/ModalBody.svelte"
2024-10-24 23:28:56 +00:00
import Button from "@lib/components/Button.svelte"
import EmojiPicker from "@lib/components/EmojiPicker.svelte"
import EventInfo from "@app/components/EventInfo.svelte"
2026-07-28 16:16:26 +00:00
import {reactions, wraps} from "@app/core"
2026-06-08 21:14:40 +00:00
import {pushModal} from "@app/modal"
import {clip} from "@app/toast"
2024-10-24 23:28:56 +00:00
2025-03-04 18:20:06 +00:00
type Props = {
pubkeys: string[]
event: TrustedEvent
reply: () => void
2026-03-10 22:13:33 +00:00
edit?: () => void
2025-03-04 18:20:06 +00:00
}
2026-03-10 22:13:33 +00:00
const {event, pubkeys, reply, edit}: Props = $props()
2024-10-24 23:28:56 +00:00
2026-07-28 16:16:26 +00:00
const onEmoji = async (emoji: NativeEmoji) => {
2024-10-24 23:28:56 +00:00
history.back()
2026-07-28 16:16:26 +00:00
const reaction = await $reactions.react(event, emoji.unicode)
return $wraps.publish({event: reaction.event, recipients: pubkeys, pow: 16})
}
2024-10-24 23:28:56 +00:00
const showEmojiPicker = () => pushModal(EmojiPicker, {onClick: onEmoji}, {replaceState: true})
2025-03-04 18:20:06 +00:00
const sendReply = () => {
history.back()
reply()
}
2026-03-10 22:13:33 +00:00
const sendEdit = () => {
history.back()
edit?.()
}
2024-10-24 23:28:56 +00:00
const copyText = () => {
history.back()
clip(event.content)
}
const showInfo = () => pushModal(EventInfo, {event}, {replaceState: true})
</script>
2026-02-09 16:49:55 +00:00
<Modal>
<ModalBody>
2026-02-10 19:39:29 +00:00
<div class="flex flex-col gap-2">
<Button class="button button-neutral" onclick={showInfo}>
2026-02-10 19:39:29 +00:00
<Icon size={4} icon={Code2} />
Message Info
</Button>
<Button class="button button-neutral w-full" onclick={copyText}>
2026-02-10 19:39:29 +00:00
<Icon size={4} icon={Copy} />
Copy Text
</Button>
<Button class="button button-neutral w-full" onclick={sendReply}>
2026-02-10 19:39:29 +00:00
<Icon size={4} icon={Reply} />
Send Reply
</Button>
2026-03-10 22:13:33 +00:00
{#if edit}
<Button class="button button-neutral w-full" onclick={sendEdit}>
2026-03-10 22:13:33 +00:00
<Icon size={4} icon={Pen} />
Edit Message
</Button>
{/if}
<Button class="button button-primary w-full" onclick={showEmojiPicker}>
2026-02-10 19:39:29 +00:00
<Icon size={4} icon={SmileCircle} />
Send Reaction
</Button>
</div>
2026-02-09 16:49:55 +00:00
</ModalBody>
</Modal>