For #3784: Crash loading bookmarks while detached (#3787)

nightly-build-test
Colin Lee 5 years ago committed by GitHub
parent 386a3f3acc
commit 7473126f7c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -28,6 +28,7 @@ import kotlinx.android.synthetic.main.fragment_bookmark.view.*
import kotlinx.coroutines.Dispatchers.IO
import kotlinx.coroutines.Dispatchers.Main
import kotlinx.coroutines.Job
import kotlinx.coroutines.isActive
import kotlinx.coroutines.launch
import mozilla.appservices.places.BookmarkRoot
import mozilla.components.concept.storage.BookmarkNode
@ -122,11 +123,12 @@ class BookmarkFragment : Fragment(), BackHandler, AccountObserver {
}
private fun loadInitialBookmarkFolder(currentGuid: String): Job {
return lifecycleScope.launch(IO) {
return viewLifecycleOwner.lifecycleScope.launch(IO) {
currentRoot =
context?.bookmarkStorage()?.getTree(currentGuid).withOptionalDesktopFolders(context) as BookmarkNode
lifecycleScope.launch(Main) {
if (!isActive) return@launch
launch(Main) {
getManagedEmitter<BookmarkChange>().onNext(BookmarkChange.Change(currentRoot!!))
activity?.run {

Loading…
Cancel
Save