@ -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 ( )