diff --git a/app/src/main/java/org/mozilla/fenix/library/bookmarks/BookmarkFragment.kt b/app/src/main/java/org/mozilla/fenix/library/bookmarks/BookmarkFragment.kt index 7cd78ff2c..b0e3c3a5c 100644 --- a/app/src/main/java/org/mozilla/fenix/library/bookmarks/BookmarkFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/library/bookmarks/BookmarkFragment.kt @@ -19,6 +19,8 @@ import androidx.lifecycle.lifecycleScope import androidx.navigation.NavDirections import androidx.navigation.fragment.findNavController import kotlinx.android.synthetic.main.fragment_bookmark.view.* +import kotlinx.coroutines.async +import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers.IO import kotlinx.coroutines.Dispatchers.Main import kotlinx.coroutines.ExperimentalCoroutinesApi @@ -26,6 +28,7 @@ import kotlinx.coroutines.Job import kotlinx.coroutines.ObsoleteCoroutinesApi import kotlinx.coroutines.isActive import kotlinx.coroutines.launch +import kotlinx.coroutines.awaitAll import mozilla.appservices.places.BookmarkRoot import mozilla.components.concept.storage.BookmarkNode import mozilla.components.concept.storage.BookmarkNodeType @@ -257,8 +260,14 @@ class BookmarkFragment : LibraryPageFragment(), BackHandler, Accou } private suspend fun deleteSelectedBookmarks(selected: Set) { - selected.forEach { - context?.bookmarkStorage?.deleteNode(it.guid) + CoroutineScope(IO).launch { + val tempStorage = context?.bookmarkStorage + val deferreds = selected.map { + async { + tempStorage?.deleteNode(it.guid) + } + } + deferreds.awaitAll() } }