2021-07-21 10:19:51 +00:00
|
|
|
<template>
|
2021-12-27 14:46:39 +00:00
|
|
|
<div class="comment flex mt-1.5">
|
2021-10-08 18:52:51 +00:00
|
|
|
<img
|
|
|
|
:src="comment.thumbnail"
|
2021-12-27 14:46:36 +00:00
|
|
|
class="comment-avatar rounded-full w-12 h-12"
|
2021-11-01 20:23:04 +00:00
|
|
|
height="48"
|
|
|
|
width="48"
|
2021-10-08 18:52:51 +00:00
|
|
|
loading="lazy"
|
|
|
|
alt="Avatar"
|
|
|
|
/>
|
2021-07-21 10:19:51 +00:00
|
|
|
|
2021-12-27 14:46:36 +00:00
|
|
|
<div class="comment-content pl-2">
|
2021-10-08 18:52:51 +00:00
|
|
|
<div class="comment-header">
|
2022-01-12 11:27:08 +00:00
|
|
|
<div v-if="comment.pinned" class="comment-pinned">
|
2021-12-27 22:33:55 +00:00
|
|
|
<font-awesome-icon icon="thumbtack" />
|
2022-01-30 23:48:27 +00:00
|
|
|
<span class="ml-1.5" v-t="'comment.pinned_by'" />
|
2021-12-27 16:29:25 +00:00
|
|
|
<span v-text="uploader" />
|
2021-10-08 18:52:51 +00:00
|
|
|
</div>
|
2021-07-21 10:19:51 +00:00
|
|
|
|
2021-10-08 18:52:51 +00:00
|
|
|
<div class="comment-author">
|
2022-05-19 21:17:58 +00:00
|
|
|
<router-link class="font-bold link" :to="comment.commentorUrl">{{ comment.author }}</router-link>
|
2021-12-27 22:33:55 +00:00
|
|
|
<font-awesome-icon class="ml-1.5" v-if="comment.verified" icon="check" />
|
2021-10-08 18:52:51 +00:00
|
|
|
</div>
|
2022-01-12 11:27:08 +00:00
|
|
|
<div class="comment-meta text-sm mb-1.5" v-text="comment.commentedTime" />
|
2021-10-08 18:52:51 +00:00
|
|
|
</div>
|
2022-09-10 17:15:38 +00:00
|
|
|
<div class="whitespace-pre-wrap" v-html="urlify(comment.commentText)" />
|
2022-08-17 13:34:57 +00:00
|
|
|
<div class="comment-footer mt-1 flex">
|
|
|
|
<div class="i-fa-solid:thumbs-up" />
|
2021-12-27 16:29:25 +00:00
|
|
|
<span class="ml-1" v-text="numberFormat(comment.likeCount)" />
|
2021-12-27 22:33:55 +00:00
|
|
|
<font-awesome-icon class="ml-1" v-if="comment.hearted" icon="heart" />
|
2021-10-08 18:52:51 +00:00
|
|
|
</div>
|
2021-11-04 10:52:28 +00:00
|
|
|
<template v-if="comment.repliesPage && (!loadingReplies || !showingReplies)">
|
2022-01-14 01:31:15 +00:00
|
|
|
<div @click="loadReplies" class="cursor-pointer">
|
2022-01-12 11:27:08 +00:00
|
|
|
<a v-t="'actions.show_replies'" />
|
2021-12-27 14:46:39 +00:00
|
|
|
<font-awesome-icon class="ml-1.5" icon="level-down-alt" />
|
2021-11-01 20:23:04 +00:00
|
|
|
</div>
|
2021-11-04 10:52:28 +00:00
|
|
|
</template>
|
|
|
|
<template v-if="showingReplies">
|
2022-01-14 01:31:15 +00:00
|
|
|
<div @click="hideReplies" class="cursor-pointer">
|
2022-01-12 11:27:08 +00:00
|
|
|
<a v-t="'actions.hide_replies'" />
|
2021-12-27 14:46:39 +00:00
|
|
|
<font-awesome-icon class="ml-1.5" icon="level-up-alt" />
|
2021-11-04 10:52:28 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
2021-12-27 14:46:36 +00:00
|
|
|
<div v-show="showingReplies" v-if="replies" class="replies">
|
|
|
|
<div v-for="reply in replies" :key="reply.commentId" class="w-full">
|
2022-01-13 05:12:06 +00:00
|
|
|
<CommentItem :comment="reply" :uploader="uploader" :video-id="videoId" />
|
2021-11-01 20:23:04 +00:00
|
|
|
</div>
|
2022-01-14 01:31:15 +00:00
|
|
|
<div v-if="nextpage" @click="loadReplies" class="cursor-pointer">
|
2022-01-12 11:27:08 +00:00
|
|
|
<a v-t="'actions.load_more_replies'" />
|
2021-12-27 14:46:39 +00:00
|
|
|
<font-awesome-icon class="ml-1.5" icon="level-down-alt" />
|
2021-11-01 20:23:04 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2021-07-21 10:19:51 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2021-10-08 18:52:51 +00:00
|
|
|
export default {
|
2021-07-21 10:19:51 +00:00
|
|
|
props: {
|
2021-10-08 18:52:51 +00:00
|
|
|
comment: {
|
|
|
|
type: Object,
|
|
|
|
default: () => {
|
|
|
|
return {};
|
|
|
|
},
|
|
|
|
},
|
|
|
|
uploader: { type: String, default: null },
|
2021-11-01 20:23:04 +00:00
|
|
|
videoId: { type: String, default: null },
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
2021-11-04 10:52:28 +00:00
|
|
|
loadingReplies: false,
|
|
|
|
showingReplies: false,
|
2021-11-01 20:23:04 +00:00
|
|
|
replies: [],
|
|
|
|
nextpage: null,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
methods: {
|
2021-11-04 10:52:28 +00:00
|
|
|
async loadReplies() {
|
|
|
|
if (!this.showingReplies && this.loadingReplies) {
|
|
|
|
this.showingReplies = true;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.loadingReplies = true;
|
|
|
|
this.showingReplies = true;
|
2021-11-01 20:23:04 +00:00
|
|
|
this.fetchJson(this.apiUrl() + "/nextpage/comments/" + this.videoId, {
|
|
|
|
nextpage: this.nextpage || this.comment.repliesPage,
|
|
|
|
}).then(json => {
|
|
|
|
this.replies = this.replies.concat(json.comments);
|
|
|
|
this.nextpage = json.nextpage;
|
|
|
|
});
|
|
|
|
},
|
2021-11-04 10:52:28 +00:00
|
|
|
async hideReplies() {
|
|
|
|
this.showingReplies = false;
|
|
|
|
},
|
2021-10-08 18:52:51 +00:00
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|