Fix crash when canceling library update with new chapters

This commit is contained in:
Jay 2020-08-09 17:45:56 -04:00
parent 06ee5439d1
commit 20e81073aa

View File

@ -28,6 +28,7 @@ import eu.kanade.tachiyomi.util.system.notificationBuilder
import eu.kanade.tachiyomi.util.system.notificationManager
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import okhttp3.internal.toImmutableMap
import uy.kohesive.injekt.injectLazy
import java.util.ArrayList
@ -121,7 +122,9 @@ class LibraryUpdateNotifier(private val context: Context) {
*
* @param updates a list of manga with new updates.
*/
fun showResultNotification(updates: Map<LibraryManga, Array<Chapter>>) {
fun showResultNotification(newUpdates: Map<LibraryManga, Array<Chapter>>) {
// create a copy of the list since it will be cleared by the time it is used
val updates = newUpdates.toImmutableMap()
GlobalScope.launch {
val notifications = ArrayList<Pair<Notification, Int>>()
updates.forEach {