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
This commit is contained in:
Melih 2023-01-30 04:43:46 +01:00 committed by GitHub
parent 7640a93ec9
commit 5fd236d963
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 11 deletions

View File

@ -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