diff --git a/frontend/src/components/Post.vue b/frontend/src/components/Post.vue index 6c3ffd3..f3dd26a 100644 --- a/frontend/src/components/Post.vue +++ b/frontend/src/components/Post.vue @@ -2,14 +2,11 @@ import Avatar from '@/components/Avatar.vue'; import 'moment/dist/locale/ja'; import moment from 'moment-timezone'; -import { computed, effect, ref } from 'vue'; -import { reactionIcons } from '@/features/reactions'; +import { computed, ref } from 'vue'; import ConditionalLink from '@/components/ConditionalLink.vue'; -import { deleteReaction, postReaction } from '@/features/api'; import { Icon } from '@iconify/vue'; -import twemoji from 'twemoji'; - -type Reaction = { id: number; count: number; clicked: boolean }; +import type { Reaction } from '@/components/PostReactions.vue'; +import PostReactions from '@/components/PostReactions.vue'; const props = defineProps<{ id: string; @@ -20,51 +17,21 @@ const props = defineProps<{ detail?: boolean; reactions: Reaction[]; }>(); -const emits = defineEmits<{ +const emit = defineEmits<{ (e: 'react'): void; }>(); -const copiedReactions = ref(props.reactions); -effect(() => { - copiedReactions.value = props.reactions; -}); -const newReaction = ref(-1); - function getDateText() { return moment(props.date).fromNow(); } const dateText = ref(getDateText()); -async function toggleReaction(reaction: Reaction) { - const r = copiedReactions.value.find((r) => r.id == reaction.id)!; - if (reaction.clicked) { - r.clicked = false; - r.count--; - await deleteReaction(props.id, reaction.id); - emits('react'); - } else { - r.clicked = true; - r.count++; - newReaction.value = reaction.id; - await postReaction(props.id, reaction.id); - emits('react'); - } -} - const shareText = computed(() => encodeURIComponent( `:@${props.name}: < ${props.content}\n\n[:fire: 発火村の投稿より :fire:](https://hakka-mura.trap.show/posts/${props.id})`, ), ); - -const vTwemoji = { - mounted: (el: HTMLElement) => { - el.innerHTML = twemoji.parse(el.innerHTML, { - className: 'twemoji', - }); - }, -};