@ -19,6 +19,8 @@ import androidx.lifecycle.lifecycleScope
import androidx.navigation.NavDirections
import androidx.navigation.NavDirections
import androidx.navigation.fragment.findNavController
import androidx.navigation.fragment.findNavController
import kotlinx.android.synthetic.main.fragment_bookmark.view.*
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.IO
import kotlinx.coroutines.Dispatchers.Main
import kotlinx.coroutines.Dispatchers.Main
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.ExperimentalCoroutinesApi
@ -26,6 +28,7 @@ import kotlinx.coroutines.Job
import kotlinx.coroutines.ObsoleteCoroutinesApi
import kotlinx.coroutines.ObsoleteCoroutinesApi
import kotlinx.coroutines.isActive
import kotlinx.coroutines.isActive
import kotlinx.coroutines.launch
import kotlinx.coroutines.launch
import kotlinx.coroutines.awaitAll
import mozilla.appservices.places.BookmarkRoot
import mozilla.appservices.places.BookmarkRoot
import mozilla.components.concept.storage.BookmarkNode
import mozilla.components.concept.storage.BookmarkNode
import mozilla.components.concept.storage.BookmarkNodeType
import mozilla.components.concept.storage.BookmarkNodeType
@ -257,8 +260,14 @@ class BookmarkFragment : LibraryPageFragment<BookmarkNode>(), BackHandler, Accou
}
}
private suspend fun deleteSelectedBookmarks ( selected : Set < BookmarkNode > ) {
private suspend fun deleteSelectedBookmarks ( selected : Set < BookmarkNode > ) {
selected . forEach {
CoroutineScope ( IO ) . launch {
context ?. bookmarkStorage ?. deleteNode ( it . guid )
val tempStorage = context ?. bookmarkStorage
val deferreds = selected . map {
async {
tempStorage ?. deleteNode ( it . guid )
}
}
deferreds . awaitAll ( )
}
}
}
}