From 5fd236d9630668f7179056bec92b811ded361a99 Mon Sep 17 00:00:00 2001 From: Melih Date: Mon, 30 Jan 2023 04:43:46 +0100 Subject: [PATCH] Fix video fetch when using invidious API and sorting by popular. (#3126) * Fix video fetch when using invidious API and also sorting by popular. * Remove redundant latestVideosPage variable --- src/renderer/views/Channel/Channel.js | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/renderer/views/Channel/Channel.js b/src/renderer/views/Channel/Channel.js index 27e8e780b..778b83bfb 100644 --- a/src/renderer/views/Channel/Channel.js +++ b/src/renderer/views/Channel/Channel.js @@ -43,7 +43,6 @@ export default defineComponent({ bannerUrl: '', thumbnailUrl: '', subCount: 0, - latestVideosPage: 2, searchPage: 2, videoContinuationString: '', playlistContinuationString: '', @@ -181,7 +180,6 @@ export default defineComponent({ this.id = this.$route.params.id this.idType = this.$route.query.idType ? Number(this.$route.query.idType) : 0 this.currentTab = this.$route.params.currentTab ?? 'videos' - this.latestVideosPage = 2 this.searchPage = 2 this.relatedChannels = [] this.latestVideos = [] @@ -209,8 +207,7 @@ export default defineComponent({ this.getChannelVideosLocal() break case 'invidious': - this.latestVideosPage = 1 - this.channelInvidiousNextPage() + this.channelInvidiousVideos() break default: this.getChannelVideosLocal() @@ -226,7 +223,7 @@ export default defineComponent({ this.getPlaylistsLocal() break case 'invidious': - this.channelInvidiousNextPage() + this.getPlaylistsInvidious() break default: this.getPlaylistsLocal() @@ -416,23 +413,23 @@ export default defineComponent({ }) }, - channelInvidiousNextPage: function () { + channelInvidiousVideos: function (fetchMore) { const payload = { resource: 'channels/videos', id: this.id, params: { sort_by: this.videoSortBy, - page: this.latestVideosPage } } + if (fetchMore) payload.params.continuation = this.videoContinuationString invidiousAPICall(payload).then((response) => { - this.latestVideos = this.latestVideos.concat(response) - this.latestVideosPage++ + this.latestVideos = this.latestVideos.concat(response.videos) + this.videoContinuationString = response.continuation this.isElementListLoading = false }).catch((err) => { console.error(err) - const errorMessage = this.$t('Local API Error (Click to copy)') + const errorMessage = this.$t('Invidious API Error (Click to copy)') showToast(`${errorMessage}: ${err}`, 10000, () => { copyToClipboard(err) }) @@ -629,7 +626,7 @@ export default defineComponent({ this.channelLocalNextPage() break case 'invidious': - this.channelInvidiousNextPage() + this.channelInvidiousVideos(true) break } break