flotilla/src/app/components/ChatMessageMenuMobile.svelte

66 lines
2 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"
2025-05-05 17:11:02 +00:00
import {sendWrapped} from "@welshman/app"
2024-10-24 23:28:56 +00:00
import Icon from "@lib/components/Icon.svelte"
import Button from "@lib/components/Button.svelte"
import EmojiPicker from "@lib/components/EmojiPicker.svelte"
import EventInfo from "@app/components/EventInfo.svelte"
import {makeReaction} from "@app/core/commands"
import {pushModal} from "@app/util/modal"
import {clip} from "@app/util/toast"
2025-09-10 22:26:39 +00:00
import SmileCircle from "@assets/icons/smile-circle.svg?dataurl"
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
2025-03-04 18:20:06 +00:00
type Props = {
pubkeys: string[]
event: TrustedEvent
reply: () => void
}
const {event, pubkeys, reply}: Props = $props()
2024-10-24 23:28:56 +00:00
2025-04-03 22:40:52 +00:00
const onEmoji = ((event: TrustedEvent, pubkeys: string[], emoji: NativeEmoji) => {
2024-10-24 23:28:56 +00:00
history.back()
sendWrapped({
event: makeReaction({event, content: emoji.unicode, protect: false}),
recipients: pubkeys,
})
2025-04-03 22:40:52 +00:00
}).bind(undefined, event, pubkeys)
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()
}
2024-10-24 23:28:56 +00:00
const copyText = () => {
history.back()
clip(event.content)
}
const showInfo = () => pushModal(EventInfo, {event}, {replaceState: true})
</script>
<div class="col-2">
2025-12-08 17:19:41 +00:00
<Button class="btn btn-neutral" onclick={showInfo}>
<Icon size={4} icon={Code2} />
Message Info
2025-03-04 18:20:06 +00:00
</Button>
<Button class="btn btn-neutral w-full" onclick={copyText}>
2025-09-10 22:26:39 +00:00
<Icon size={4} icon={Copy} />
2024-10-24 23:28:56 +00:00
Copy Text
</Button>
2025-12-08 17:19:41 +00:00
<Button class="btn btn-neutral w-full" onclick={sendReply}>
<Icon size={4} icon={Reply} />
Send Reply
</Button>
<Button class="btn btn-primary w-full" onclick={showEmojiPicker}>
<Icon size={4} icon={SmileCircle} />
Send Reaction
2024-10-24 23:28:56 +00:00
</Button>
</div>