Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/renderer/views/Playlist/Playlist.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -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
}
Expand All @@ -308,6 +318,7 @@ export default defineComponent({
}

this.isLoadingMore = false
if (shouldGetNextPage) { this.getNextPageLocal() }
})
},

Expand Down