* Update playlist view to auto load next page for local API to workaround issue of useless continuation data (#4519)

This commit is contained in:
PikachuEXE 2024-01-06 18:27:17 +08:00 committed by GitHub
parent baa7b014eb
commit f25b537901
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 0 deletions

View File

@ -199,9 +199,14 @@ export default defineComponent({
this.playlistItems = result.items.map(parseLocalPlaylistVideo)
let shouldGetNextPage = false
if (result.has_continuation) {
this.continuationData = result
shouldGetNextPage = this.playlistItems.length < 100
}
// To workaround the effect of useless continuation data
// auto load next page again when no. of parsed items < page size
if (shouldGetNextPage) { this.getNextPageLocal() }
this.isLoading = false
}).catch((err) => {
@ -294,12 +299,17 @@ export default defineComponent({
this.isLoadingMore = true
getLocalPlaylistContinuation(this.continuationData).then((result) => {
let shouldGetNextPage = false
if (result) {
const parsedVideos = result.items.map(parseLocalPlaylistVideo)
this.playlistItems = this.playlistItems.concat(parsedVideos)
if (result.has_continuation) {
this.continuationData = result
// To workaround the effect of useless continuation data
// auto load next page again when no. of parsed items < page size
shouldGetNextPage = parsedVideos.length < 100
} else {
this.continuationData = null
}
@ -308,6 +318,7 @@ export default defineComponent({
}
this.isLoadingMore = false
if (shouldGetNextPage) { this.getNextPageLocal() }
})
},