Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
46 lines
1.2 KiB
Vue
46 lines
1.2 KiB
Vue
<script setup lang="ts">
|
|
import { toast } from 'vue-sonner'
|
|
import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover'
|
|
|
|
const props = defineProps<{ commentId: number }>()
|
|
|
|
const { toggle } = useCommentReactions()
|
|
const { t } = useI18n()
|
|
|
|
const open = ref(false)
|
|
const busy = ref(false)
|
|
|
|
async function pick(emoji: string, sticker = false) {
|
|
if (busy.value) return
|
|
busy.value = true
|
|
open.value = false
|
|
try {
|
|
await toggle(props.commentId, emoji, sticker)
|
|
}
|
|
catch (err) {
|
|
const e = err as { data?: { statusMessage?: string } }
|
|
toast.error(e.data?.statusMessage ?? t('comments.reactionFailed'))
|
|
}
|
|
finally {
|
|
busy.value = false
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<template>
|
|
<Popover v-model:open="open">
|
|
<PopoverTrigger as-child>
|
|
<button
|
|
type="button"
|
|
class="cursor-pointer self-center rounded-md p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground"
|
|
:aria-label="$t('comments.addReaction')"
|
|
>
|
|
<Icon name="ph:smiley-fill" class="size-5" />
|
|
</button>
|
|
</PopoverTrigger>
|
|
<PopoverContent v-if="open" align="end" class="w-auto overflow-hidden p-0">
|
|
<EmojiStickerPicker @select="pick" />
|
|
</PopoverContent>
|
|
</Popover>
|
|
</template>
|