Skip to content

Commit db62c9f

Browse files
committed
Extract dequeue logic into function
1 parent 45b34f7 commit db62c9f

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

server/src/main/kotlin/suwayomi/tachidesk/manga/impl/download/DownloadManager.kt

+7-6
Original file line numberDiff line numberDiff line change
@@ -289,16 +289,17 @@ object DownloadManager {
289289

290290
fun dequeue(input: EnqueueInput) {
291291
if (input.chapterIds.isNullOrEmpty()) return
292-
293-
downloadQueue.removeIf { it.chapter.id in input.chapterIds }
294-
saveDownloadQueue()
295-
296-
notifyAllClients()
292+
dequeue(downloadQueue.filter { it.chapter.id in input.chapterIds }.toSet())
297293
}
298294

299295
fun dequeue(chapterIndex: Int, mangaId: Int) {
300-
downloadQueue.removeIf { it.mangaId == mangaId && it.chapterIndex == chapterIndex }
296+
dequeue(downloadQueue.filter { it.mangaId == mangaId && it.chapterIndex == chapterIndex }.toSet())
297+
}
298+
299+
private fun dequeue(chapterDownloads: Set<DownloadChapter>) {
300+
downloadQueue.removeAll(chapterDownloads)
301301
saveDownloadQueue()
302+
302303
notifyAllClients()
303304
}
304305

0 commit comments

Comments
 (0)