New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature] Bookmarks Improvement #1441
[Feature] Bookmarks Improvement #1441
Conversation
@4shutosh thanks for your time here. As I posted in the different issues you created, let's first have a discussion before we introduce any improvement. We accept contributions for bug fixes after we triage the issue and we add the label "help wanted". For feature requests/improvements, you need to open a discussion first. Inside the discussion, we will have a nice chat to know more about the proposal, understand what's the user value, etc. That's because we will need to share the proposed change with our Product team and/or Design team. If it's aligned with our roadmap and we are happy with the idea then we will be able to give you support with the improvements. Hope that's ok with you, let's close this PR for now. We can open it again once I get the internal approval. Thanks again, and I think the proposal makes sense, but we need to check internally first 👍 |
Thank you for the explanation @cmonfortep 🙌🏻 That's unfortunate but will surely do the required. I've created a discussion here #1442 |
@cmonfortep can you please reopen this PR, I'll make it as a draft and ask for approval on completion. |
# Conflicts: # app/src/main/java/com/duckduckgo/app/browser/BrowserTabViewModel.kt
Behavioral changes introduced in this PR:
@cmonfortep please review. |
Thanks @4shutosh. "The edit bookmark shows the folder name now". Sorry if it was not clear, but we discarded de idea of showing folder names in the snackbar (see my comment: https://github.com/duckduckgo/Android/discussions/1442#discussioncomment-1551699) |
Thanks. I will try to review the PR this week. Could you update the description? (just to reflect what this PR is finally addressing since we discarded some initial proposals) |
@4shutosh just to give you some heads up. Testing this right now, looks great. Our designer is taking a look, should give me feedback on Monday. |
Thank you for the update 🙌🏻 |
@4shutosh thank you for your patience. Feedback from the design team was really positive, that's really cool! They only asked if we can take the user back to the edit screen when the user created the new folder (same as in chrome). Feedback is optional and I haven't checked how complex it is, so let me know if you are interested (and if you have time, it's ok if you can't) or not. In case you want to contribute on that, you can do it here or in another PR. |
That's great! I'm interested in working on the feedback. But I'll be able to do that (or any test related progress of this PR: as some tests are failing) after a week. Please proceed with the tests fix if this feature is of priority for upcoming release within a week. In that case, I'll be continuing the feedback work on a new PR. |
Sounds good, I will review this PR as it is now, and further improvements can be done on a separated PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @4shutosh, haven't reviewed all the changes. I've only focused on the dialogs and the browsertabviewmodel. Left some comments bellow.
While testing this, I've noticed an unexpected behavior: After editing a bookmark (changing folder), a snackbar saying "bookmark added" appears. Testing our latest app, the behavior is different. We only show the snackbar when the user adds a new bookmark, not after editing the bookmark.
app/src/main/java/com/duckduckgo/app/bookmarks/ui/SavedSiteDialogFragment.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/com/duckduckgo/app/browser/BrowserTabViewModel.kt
Outdated
Show resolved
Hide resolved
Sorry for the delay. @cmonfortep This is getting stretched more than expected. I'll try my best to complete the changes related to this PR as early as possible now. Please help me with the review. Thank you again. 🙌🏻 |
@cmonfortep can you check on this? |
@4shutosh sorry for the delay here, Christmas break + workload got me busy. I'm going to review this ASAP. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks and sorry for the delay in the review. As you said, this is taking longer than we expected and it was difficult to remember what was missing here.
I'm leaving some comments. So far it's looking good. Just something important to mention:
- be sure new code is properly tested if the class has a test (otherwise is not necessary, e.g: activities/fragments)
- when aligning with develop, you may get lot of conflicts. We have introduced changes in our code style, so expect some conflicts there.
Thanks.
app/src/main/java/com/duckduckgo/app/browser/BrowserTabViewModel.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/com/duckduckgo/app/browser/BrowserTabViewModel.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/com/duckduckgo/app/browser/BrowserTabViewModel.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/com/duckduckgo/app/browser/BrowserTabViewModel.kt
Outdated
Show resolved
Hide resolved
@@ -82,6 +87,10 @@ class BookmarksDataRepository( | |||
return bookmarksDao.getBookmarksByParentIdSync(parentId) | |||
} | |||
|
|||
override suspend fun getBookmarkFolderByParentId(parentId: Long): BookmarkFolder? { | |||
return bookmarkFoldersDao.getBookmarkFolders().firstOrNull()?.find { it.id == parentId } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haven't checked, but I think filtering at SQL level is more efficient than getting the whole list of folders here, and then filtering. Can you create a new method in BookmarkFoldersDao
, and just use it here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Created a new method please check.
app/src/main/java/com/duckduckgo/app/bookmarks/ui/EditSavedSiteDialogFragment.kt
Outdated
Show resolved
Hide resolved
private fun editSavedSite(savedSiteChangedViewState: SavedSiteChangedViewState) { | ||
val addBookmarkDialog = EditSavedSiteDialogFragment.instance( | ||
savedSiteChangedViewState.savedSite, | ||
savedSiteChangedViewState.bookmarkFolder?.id ?: 0, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I want to check with someone from the team, what's the difference between savedSiteChangedViewState.bookmarkFolder?.id
vs savedSiteChangedViewState.savedSite.parentId
when we have a bookmark. So maybe I will ask to double check this part.
viewState.value = currentViewState().copy(currentFolder = currentFolder, selectedFolderId = selectedFolderId) | ||
} | ||
|
||
fun newFolderAdded(rootFolderName: String) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test missing for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added please check
app/src/main/java/com/duckduckgo/app/bookmarks/ui/bookmarkfolders/BookmarkFoldersViewModel.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/com/duckduckgo/app/bookmarks/ui/bookmarkfolders/BookmarkFoldersActivity.kt
Show resolved
Hide resolved
I tried to work on this. This can be done in a couple of ways as per my understanding. 1
But this will not give us the ideal behavior and the list will be visible for a split second.
Please take a look and let me know any other changes required. |
Feedback was optional. If you want to work on that, it's awesome! but my proposal is to do it on another PR once this one is merged. Just to avoid delaying more this feature. |
Sure I'll do that. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @4shutosh. We are almost done here 🎉
I've just left one last comment to cover with a unit test the method in the repository. I've tested the functionality and it works as expected.
@@ -96,6 +100,10 @@ class BookmarksDataRepository( | |||
return bookmarksDao.getBookmarksByParentIdSync(parentId) | |||
} | |||
|
|||
override suspend fun getBookmarkFolderByParentId(parentId: Long): BookmarkFolder { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a test to cover this method?
What will happen when parentId is not found or doesn't return any folder? Please also test that scenario.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added the test.
In that case, the bookmark is treated as if it is stored in the default root folder under the name "Bookmarks".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the changes @4shutosh LGTM!
Please, solve the conflicts with develop (probably the test has been moved into unit tests folder), and as soon as the check is green we will merge it. :)
Sharing here the stacktrace of the failing test.
|
Yes, got the problem in the test. I've pushed a commit with a change in the test. The tests should pass now. |
Yayyy 🎉 thank you for your guidance @cmonfortep 🙌🏻 |
Task/Issue URL:
#1438
#1439
#1440
PR related to the feature proposal mentioned in discussion #1442
Description
BrowserFragment
Steps to test this PR