Prevent UnsupportedOperationException in DownloadManager (#1521)

CopyOnWriteArraySet does not support the usage of "removeAll" with a predicate
This commit is contained in:
schroda
2025-07-15 15:32:11 +02:00
committed by GitHub
parent 7c506a42ae
commit 3bac176bf6

View File

@@ -168,12 +168,14 @@ object DownloadManager {
downloads: List<DownloadUpdate> = emptyList(),
gqlEmit: Boolean = false,
) {
downloadUpdates.removeAll { update ->
val outdatedUpdates =
downloadUpdates.filter { update ->
downloads.any { download ->
download.downloadChapter.chapter.id ==
update.downloadChapter.chapter.id
}
}
downloadUpdates.removeAll(outdatedUpdates)
downloadUpdates.addAll(downloads)
// There is a problem where too many immediate updates can cause the client to lag out (e.g., in case it has to