For #11502: Make sure to always process root titles for parent folders during edit

This also switches to a simpler bookmarks query API ('getBookmark') which doesn't fetch
children. We don't need 'children' for this dialog, and so don't need to do the extra work.
pull/149/head
Grisha Kruglov 4 years ago committed by Grisha Kruglov
parent 958474f9fb
commit b5b32ba6ea

@ -71,14 +71,22 @@ class EditBookmarkFragment : Fragment(R.layout.fragment_edit_bookmark) {
viewLifecycleOwner.lifecycleScope.launch(Main) {
val context = requireContext()
val bookmarkNodeBeforeReload = bookmarkNode
withContext(IO) {
val bookmarksStorage = context.components.core.bookmarksStorage
bookmarkNode = bookmarksStorage.getTree(args.guidToEdit)
bookmarkParent = sharedViewModel.selectedFolder
?: bookmarkNode?.parentGuid
?.let { bookmarksStorage.getTree(it) }
?.let { DesktopFolders(context, showMobileRoot = true).withRootTitle(it) }
bookmarkNode = withContext(IO) {
bookmarksStorage.getBookmark(args.guidToEdit)
}
bookmarkParent = withContext(IO) {
// Use user-selected parent folder if it's set, or node's current parent otherwise.
if (sharedViewModel.selectedFolder != null) {
sharedViewModel.selectedFolder
} else {
bookmarkNode?.parentGuid?.let { bookmarksStorage.getBookmark(it) }
}?.let {
// No-op for non-root nodes, and copies a node with a friendly title otherwise.
DesktopFolders(context, showMobileRoot = true).withRootTitle(it)
}
}
when (bookmarkNode?.type) {
@ -101,6 +109,8 @@ class EditBookmarkFragment : Fragment(R.layout.fragment_edit_bookmark) {
bookmarkParent?.let { node ->
bookmarkParentFolderSelector.text = node.title
}
bookmarkParentFolderSelector.setOnClickListener {
sharedViewModel.selectedFolder = null
nav(
@ -116,7 +126,6 @@ class EditBookmarkFragment : Fragment(R.layout.fragment_edit_bookmark) {
)
)
}
}
view.bookmarkNameEdit.apply {
requestFocus()

Loading…
Cancel
Save