1
0
mirror of https://github.com/yattee/yattee.git synced 2024-12-13 13:50:32 +05:30

Restore last played item into queue only if it's not in there yet

This commit is contained in:
Arkadiusz Fal 2022-04-16 19:51:31 +02:00
parent 0e1192bb03
commit d58ec0684c

View File

@ -198,8 +198,17 @@ extension PlayerModel {
return
}
queue = ([Defaults[.lastPlayed]] + Defaults[.queue]).compactMap { $0 }
var restoredQueue = [PlayerQueueItem?]()
if let lastPlayed = Defaults[.lastPlayed],
!Defaults[.queue].contains(where: { $0.videoID == lastPlayed.videoID })
{
restoredQueue.append(lastPlayed)
Defaults[.lastPlayed] = nil
}
restoredQueue.append(contentsOf: Defaults[.queue])
queue = restoredQueue.compactMap { $0 }
queue.forEach { item in
accounts.api.loadDetails(item) { newItem in