Conversation
e3901f8 to
0eb4fe6
Compare
|
Hmmmmm the diff is too big so something went wonky with my branching off of branches strategy. I'll let you know when this is actually... reviewable. 🤨 Edit: Fixed! |
|
This pull request has conflicts when rebasing. Could you fix it @ih-codes? 🙏 |
f920284 to
163c970
Compare
| MainActor.assumeIsolated { | ||
| guard result.isSuccess else { return } | ||
| self.removeBookmarkShortcut() | ||
| Self.removeBookmarkShortcut(withBookmarksHandler: self.bookmarksHandler) |
There was a problem hiding this comment.
I discovered a retain issue in this method as I was implementing my new unit tests. As a fix, I made it a static method since it doesn't really need self.
| let bookmarkFolderGUID: GUID | ||
| var bookmarkFolder: FxBookmarkNode? | ||
| var isShowingSearchResults = false | ||
| private var currentSearchQuery: String? |
There was a problem hiding this comment.
Added this since I refresh the current search results via a fresh bookmarks tree query after removing a bookmark.
|
|
||
| @MainActor | ||
| func removeBookmarkShortcut(quickAction: QuickActions) | ||
| static func removeBookmarkShortcut( |
There was a problem hiding this comment.
Changes in this file were to increase testability and fix a retain cycle detected in unit tests.
| /// A mock handler that returns a configurable `BookmarkFolderData` for search tests. | ||
| private final class SearchableMockBookmarksHandler: BookmarksHandler, @unchecked Sendable { |
There was a problem hiding this comment.
Turns out this was basically just a copy of our other Mock BookmarksHandler, so I deleted it.
|
This pull request has conflicts when rebasing. Could you fix it @ih-codes? 🙏 |
…lder is non-empty when we deleted that folder's contents via bookmarks search.
… backing arrays are updated. Consolidate 2 bookmarks handler mocks into one. Fix retain issue with the quick actions extension default implementation by making it a static method.
163c970 to
16f58ed
Compare
💪 Quality guardian3 tests files modified. You're a champion of test coverage! 🚀 🥇 Perfect PR sizeSmaller PRs are easier to review. Thanks for making life easy for reviewers! ✨ 💬 Description craftsmanGreat PR description! Reviewers salute you 🫡 ✅ New file code coverageNo new file detected so code coverage gate wasn't ran. Client.app: Coverage: 39.4
libStorage.a: Coverage: 55.46
Generated by 🚫 Danger Swift against 16f58ed |
Foxbolts
left a comment
There was a problem hiding this comment.
Looks good, thanks for fixing this.
I think you would need to have a pretty large number of bookmarks for the DB update to be slow enough to warrant putting a fix in for the race condition, so I agree with you that it's not much of a concern
|
🚀 PR merged to |
📜 Tickets
Jira ticket
Github issue
💡 Description
The bug is a bit hard to describe, see the video in FXIOS-15296.
The tldr; is that when you are in search mode, and use the long-press context menu to delete all the bookmarks in a bookmark folder, then exit search mode, and then try to delete that folder, a warning pops up for deleting a "non empty" folder. We expect no warning should pop up, because the folder is now actually empty.
Fix
This PR fixes the folder alert issue by adding an extra reload of the bookmarks tree after a bookmark deletion while in search mode.
If a user is extremely fast I'm sure you'd still see the warning, but re-fetching bookmarks seemed quite fast for me (though I don't have that many bookmarks synced). I think there is a low chance of this edge case coming up so I'm not too concerned about this, and it's documented in the code.
Background Info
The fix is to reload the bookmarks tree after deleting a bookmark while in search mode. Unfortunately the backing bookmarks data and the search result bookmarks data are two separate backing arrays that need to both be updated. This is less than ideal. 😕
Ideally the search results would just filter the real backing data and we'd fetch the bookmarks tree with
recursive: true, but writing logic to update the tree in place (for optimistic UI updates like deleting a bookmark) will take some work. There is a separate ticket for that here (FXIOS-15309 / #32870), but I don't expect anyone will tackle this anytime soon.Testing Instructions
ℹ️ To test this new feature, please turn the
bookmarks-search-featuretotruein the nimbus feature yaml (no debug toggle yet, sorry).📝 Checklist