mirror of
https://github.com/yattee/yattee.git
synced 2025-01-08 18:40:33 +05:30
Remove duplicit videos from next playlist page response
This commit is contained in:
parent
73b4ac8ba3
commit
240f085f98
@ -195,9 +195,14 @@ struct PlaylistsView: View {
|
|||||||
response in
|
response in
|
||||||
if let nextPagePlaylist: Playlist = response.typedContent() {
|
if let nextPagePlaylist: Playlist = response.typedContent() {
|
||||||
if !nextPagePlaylist.videos.isEmpty {
|
if !nextPagePlaylist.videos.isEmpty {
|
||||||
var currentPlaylist = self.userPlaylist.item
|
var updatedPlaylist = self.userPlaylist.item
|
||||||
currentPlaylist!.videos.append(contentsOf: nextPagePlaylist.videos)
|
let currentVideoIDs = Set(updatedPlaylist?.videos.map { $0.videoID } ?? [])
|
||||||
self.userPlaylist.replace(currentPlaylist!)
|
// XXX: Invidious API returns duplicit videos, remove once fixed on Invidious side
|
||||||
|
let newVideos = nextPagePlaylist.videos.filter { !currentVideoIDs.contains($0.videoID) }
|
||||||
|
updatedPlaylist?.videos.append(contentsOf: newVideos)
|
||||||
|
if !newVideos.isEmpty {
|
||||||
|
self.userPlaylist.replace(updatedPlaylist!)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
self.canFetchMoreData = false
|
self.canFetchMoreData = false
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user