Fix crashing when reordering downloads

This commit is contained in:
FooIbar committed 2023-09-10 21:18:23 +08:00
1 parent 6f22269d93
commit 6bfa8d1ea4
1 file changed
+5 -1
@@ -462,7 +462,11 @@ object DownloadManager : OnSpiderListener {
fun moveDownload(fromItem: DownloadInfo, toItem: DownloadInfo): List<DownloadInfo> {
val fromPosition = allInfoList.indexOf(fromItem)
val toPosition = allInfoList.indexOf(toItem)
return moveDownload(fromPosition, toPosition)
return if (fromPosition != -1 && toPosition != -1) {
moveDownload(fromPosition, toPosition)
} else {
emptyList()
}
}
suspend fun resetAllReadingProgress() = coroutineScope {