@ -71,14 +71,22 @@ class EditBookmarkFragment : Fragment(R.layout.fragment_edit_bookmark) {
viewLifecycleOwner . lifecycleScope . launch ( Main ) {
viewLifecycleOwner . lifecycleScope . launch ( Main ) {
val context = requireContext ( )
val context = requireContext ( )
val bookmarkNodeBeforeReload = bookmarkNode
val bookmarkNodeBeforeReload = bookmarkNode
val bookmarksStorage = context . components . core . bookmarksStorage
withContext ( IO ) {
bookmarkNode = withContext ( IO ) {
val bookmarksStorage = context . components . core . bookmarksStorage
bookmarksStorage . getBookmark ( args . guidToEdit )
bookmarkNode = bookmarksStorage . getTree ( args . guidToEdit )
}
bookmarkParent = sharedViewModel . selectedFolder
?: bookmarkNode ?. parentGuid
bookmarkParent = withContext ( IO ) {
?. let { bookmarksStorage . getTree ( it ) }
// Use user-selected parent folder if it's set, or node's current parent otherwise.
?. let { DesktopFolders ( context , showMobileRoot = true ) . withRootTitle ( it ) }
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 ) {
when ( bookmarkNode ?. type ) {
@ -101,21 +109,22 @@ class EditBookmarkFragment : Fragment(R.layout.fragment_edit_bookmark) {
bookmarkParent ?. let { node ->
bookmarkParent ?. let { node ->
bookmarkParentFolderSelector . text = node . title
bookmarkParentFolderSelector . text = node . title
bookmarkParentFolderSelector . setOnClickListener {
}
sharedViewModel . selectedFolder = null
nav (
bookmarkParentFolderSelector . setOnClickListener {
R . id . bookmarkEditFragment ,
sharedViewModel . selectedFolder = null
EditBookmarkFragmentDirections
nav (
. actionBookmarkEditFragmentToBookmarkSelectFolderFragment (
R . id . bookmarkEditFragment ,
allowCreatingNewFolder = false ,
EditBookmarkFragmentDirections
// Don't allow moving folders into themselves.
. actionBookmarkEditFragmentToBookmarkSelectFolderFragment (
hideFolderGuid = when ( bookmarkNode !! . type ) {
allowCreatingNewFolder = false ,
BookmarkNodeType . FOLDER -> bookmarkNode !! . guid
// Don't allow moving folders into themselves.
else -> null
hideFolderGuid = when ( bookmarkNode !! . type ) {
}
BookmarkNodeType . FOLDER -> bookmarkNode !! . guid
)
else -> null
)
}
}
)
)
}
}
view . bookmarkNameEdit . apply {
view . bookmarkNameEdit . apply {