Skip to content
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

Refactor FXIOS-10924 - Remove Deferred from FolderHierarchyFetcher #23900

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

PARAIPAN9
Copy link
Collaborator

@PARAIPAN9 PARAIPAN9 commented Dec 19, 2024

📜 Tickets

Jira ticket
Github issue

💡 Description

  • Define RustPlacesProtocol.
  • Implement its methods.
  • Call them in DefaultFolderHierarchyFetcher.
  • Tests pass.

📝 Checklist

You have to check all boxes before merging

  • Filled in the above information (tickets numbers and description of your work)
  • Updated the PR name to follow our PR naming guidelines
  • Wrote unit tests and/or ensured the tests suite is passing
  • When working on UI, I checked and implemented accessibility (minimum Dynamic Text and VoiceOver)
  • If needed, I updated documentation / comments for complex code and public methods
  • If needed, added a backport comment (example @Mergifyio backport release/v120)

… in FolderHierarchyFetcher to ger rid of deferred
@PARAIPAN9 PARAIPAN9 requested a review from lmarceau December 19, 2024 17:53
@PARAIPAN9 PARAIPAN9 requested a review from a team as a code owner December 19, 2024 17:53
@mobiletest-ci-bot
Copy link

mobiletest-ci-bot commented Dec 19, 2024

Messages
📖 Project coverage: 33.62%
📖 Edited 4 files
📖 Created 0 files

Client.app: Coverage: 32.46

File Coverage
FolderHierarchyFetcher.swift 95.12%

libStorage.a: Coverage: 57.02

File Coverage
RustPlaces.swift 76.43%

Generated by 🚫 Danger Swift against 690f725

Copy link
Contributor

@lmarceau lmarceau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One little comment for a change, great work!

firefox-ios/Storage/Rust/RustPlaces.swift Outdated Show resolved Hide resolved
profile.places.getBookmarksTree(rootGUID: rootFolderGUID, recursive: true) { result in
switch result {
case .success(let data):
guard let rootFolder = data as? BookmarkFolderData else { return }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @PARAIPAN9 ! @lmarceau just wanted me to take a peek at the continuations.

There's a chance we miss calling continuation.resume here in the guard return since we don't have defer anymore. Are we explicitly removing defers as well as the Deferred?

for folder in childrenFolders ?? [] {
recursiveAddSubFolders(folder, folders: &folders, hasDesktopBookmarks: hasDesktopBookmarks)
let childrenFolders = rootFolder.children?.compactMap {
return $0 as? BookmarkFolderData
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also don't call the continuation here now either

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We call resume on both Result cases.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I see, on the guard statement you're saying.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops yeah you're right that this one is in a compactMap, but yeah the guard one is a problem!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will put defer as it was before then.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or just call the continuation in the guard would be reasonable, whichever you prefer!

If you use a defer, can you please check that the continuation doesn't get called twice with a breakpoint if possible? Since the unsafe version won't tell us if we're misusing the continuation, so we should be careful. 🙏 I'm worried the continuation resuming with folders below will also be triggered in the good case, as well as the defer, calling resume twice...

@lmarceau
Copy link
Contributor

Build failed with

❌  /Users/vagrant/git/firefox-ios/firefox-ios-tests/Tests/ClientTests/Frontend/Home/Bookmarks/BookmarksHandlerMock.swift:13:7: type 'BookmarksHandlerMock' does not conform to protocol 'BookmarksHandler'
class BookmarksHandlerMock: BookmarksHandler {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants