For #7854 - Update the views only if the bookmark node has changed
As the bookmark node data is loaded from storage every time the fragment's view is created, when the user navigates to the SelectFolderFragment and returns, the bookmark is loaded once again from storage, replacing the EditText's content (title and URL) which causes the loss of user input. Validating that the loaded bookmark is different from the one that is already referenced in the fragment avoids unnecessarily replacing the `EditText`s values.master
parent
2a5c5850fd
commit
ee62297b4c
|
@ -67,6 +67,7 @@ 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
|
||||
|
@ -89,9 +90,10 @@ class EditBookmarkFragment : Fragment(R.layout.fragment_edit_bookmark) {
|
|||
else -> throw IllegalArgumentException()
|
||||
}
|
||||
|
||||
bookmarkNode?.let { bookmarkNode ->
|
||||
bookmarkNameEdit.setText(bookmarkNode.title)
|
||||
bookmarkUrlEdit.setText(bookmarkNode.url)
|
||||
val currentBookmarkNode = bookmarkNode
|
||||
if (currentBookmarkNode != null && currentBookmarkNode != bookmarkNodeBeforeReload) {
|
||||
bookmarkNameEdit.setText(currentBookmarkNode.title)
|
||||
bookmarkUrlEdit.setText(currentBookmarkNode.url)
|
||||
}
|
||||
|
||||
bookmarkParent?.let { node ->
|
||||
|
|
Loading…
Reference in New Issue