Bug 2024810 - Fixed last saved folder cache updating#215
Conversation
|
View this pull request in Lando to land it once approved. |
| exitBookmarks() | ||
| } | ||
| val popped = getNavController().popBackStack() | ||
| lifecycleScope.launch { |
There was a problem hiding this comment.
The scope was changed to be a cancel able scope in February which made the following code not run since exitBookmarks would destroy the fragment which cancels the lifecycleScope causing the last saved pref not to get updated.
156f54a to
7bbf6ec
Compare
| scope.launch(ioDispatcher) { | ||
| val parentGuid = settings.lastSavedFolderCache.getGuid() ?: BookmarkRoot.Mobile.id | ||
| val parentNode = bookmarksStorage.getBookmark(parentGuid).getOrNull() | ||
| val targetParentFolderId = |
There was a problem hiding this comment.
You can add a bookmark star to the toolbar which didnt have the previously added safeguard to the menudialog.
segunfamisa
left a comment
There was a problem hiding this comment.
Thanks for this PR. I added a comment about something I think we should fix once-and for all, but also okay with having this as a follow-up
| val targetParentFolderId = | ||
| settings.lastSavedFolderCache.getGuid() ?: BookmarkRoot.Mobile.id | ||
|
|
||
| val parentNode = bookmarksStorage.getBookmark(targetParentFolderId).getOrNull() | ||
| ?: bookmarksStorage.getBookmark(BookmarkRoot.Mobile.id).getOrNull() | ||
| val parentGuid = parentNode?.guid ?: BookmarkRoot.Mobile.id | ||
|
|
||
| if (targetParentFolderId != parentGuid) { | ||
| settings.lastSavedFolderCache.setGuid(null) | ||
| } | ||
|
|
There was a problem hiding this comment.
To be honest, I think that we should fix this once and for-all, and make our AddBookmarksUseCase do all of this dance.
This is pretty much duplicated code from the MenuDialogMiddleware, doing the same thing.
We discussed this in January and we all kinda agreed that we need to unify this functionality. I think this is a good opportunity to do so.
I also see that you clear the last saved folder cache if for some reason, the resolved parentGuid is not matching the last saved parent folder. That's a good improvement
So, instead of duplicating this logic, we could consider the following:
- Move
LastSavedFolderCachesomewhere in our bookmarks package or something - Add it as a parameter to our AddBookmarksUsecase
- Move this logic into the use-case.
- Remove similar duplication that we do in various places
- Update tests.
I will say that we could land this to do this properly now, but that's what we said the last time 😂
Maybe @MatthewTighe & @boek can weight in here.
There was a problem hiding this comment.
I agree, I think this is a larger amount of work so I filed a follow up for this here https://bugzilla.mozilla.org/show_bug.cgi?id=2032600
|
testing-tag explanation The follow up work will streamline this approach to make it testable |
|
Pull request closed by commit 5b47c78 |
No description provided.