diff --git a/src/components/VideoComment.vue b/src/components/VideoComment.vue index 2ce47d7..0bd1800 100644 --- a/src/components/VideoComment.vue +++ b/src/components/VideoComment.vue @@ -18,6 +18,14 @@ mdi-thumb-up {{ numberFormat(comment.likeCount) }} mdi-heart +
+ Load Replies +
+ {{ showChildComments ? 'Hide' : 'Show' }} Replies +
+
+ +
@@ -29,10 +37,37 @@ import marked from 'marked' export default { name: 'VideoComment', - props: ['comment', 'video'], + props: ['comment', 'video', 'subComment'], + data: () => ({ + requestInProgress: false, + showChildComments: true, + childComments: [] + }), methods: { numberFormat (...args) { return LibPiped.numberFormat(...args) + }, + async loadReplies () { + let nextpage = null + this.requestInProgress = true + + while (true) { + const replies = await this.$store.dispatch('auth/makeRequest', { + method: 'GET', + path: '/nextpage/comments/' + this.video.videoId, + params: { + nextpage: nextpage || this.comment.repliesPage + } + }) + + this.childComments = this.childComments.concat(replies.comments) + if (replies.nextpage) { + nextpage = replies.nextpage + } else { + break + } + } + this.requestInProgress = false } },