From 62c70fbdd60435ab96113bdee9bb2c529df0eac7 Mon Sep 17 00:00:00 2001 From: absidue <48293849+absidue@users.noreply.github.com> Date: Sat, 15 Oct 2022 06:01:58 +0200 Subject: [PATCH] Fix fetching the comments from invidious (#2721) --- .../watch-video-comments.js | 47 ++++++------------- 1 file changed, 14 insertions(+), 33 deletions(-) diff --git a/src/renderer/components/watch-video-comments/watch-video-comments.js b/src/renderer/components/watch-video-comments/watch-video-comments.js index 746fc256..a61a58c6 100644 --- a/src/renderer/components/watch-video-comments/watch-video-comments.js +++ b/src/renderer/components/watch-video-comments/watch-video-comments.js @@ -104,14 +104,7 @@ export default Vue.extend({ case 'invidious': this.isLoading = true this.commentData = [] - this.getCommentDataInvidious({ - resource: 'comments', - id: this.id, - params: { - continuation: this.nextPageToken, - sort_by: this.sortNewest ? 'new' : 'top' - } - }) + this.getCommentDataInvidious() break } }, @@ -128,14 +121,7 @@ export default Vue.extend({ }) break case 'invidious': - this.getCommentDataInvidious({ - resource: 'comments', - id: this.id, - params: { - continuation: this.nextPageToken, - sort_by: this.sortNewest ? 'new' : 'top' - } - }) + this.getCommentDataInvidious() break } }, @@ -184,14 +170,7 @@ export default Vue.extend({ }) if (this.backendFallback && this.backendPreference === 'local') { showToast(this.$t('Falling back to Invidious API')) - this.getCommentDataInvidious({ - resource: 'comments', - id: this.id, - params: { - continuation: this.nextPageToken, - sort_by: this.sortNewest ? 'new' : 'top' - } - }) + this.getCommentDataInvidious() } else { this.isLoading = false } @@ -211,14 +190,7 @@ export default Vue.extend({ }) if (this.backendFallback && this.backendPreference === 'local') { showToast(this.$t('Falling back to Invidious API')) - this.getCommentDataInvidious({ - resource: 'comments', - id: this.id, - params: { - continuation: this.nextPageToken, - sort_by: this.sortNewest ? 'new' : 'top' - } - }) + this.getCommentDataInvidious() } else { this.isLoading = false } @@ -274,7 +246,16 @@ export default Vue.extend({ } }, - getCommentDataInvidious: function (payload) { + getCommentDataInvidious: function () { + const payload = { + resource: 'comments', + id: this.id, + params: { + continuation: this.nextPageToken ?? '', + sort_by: this.sortNewest ? 'new' : 'top' + } + } + this.invidiousAPICall(payload).then((response) => { const commentData = response.comments.map((comment) => { comment.showReplies = false