1
0
Fork 0

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
Juan Goncalves 2020-04-15 10:08:09 -04:00 committed by kglazko
parent 2a5c5850fd
commit ee62297b4c
1 changed files with 5 additions and 3 deletions

View File

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