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

Add FXIOS-9744 Hide desktop bookmarks folder #23074

Merged
merged 12 commits into from
Nov 15, 2024

Conversation

MattLichtenstein
Copy link
Collaborator

@MattLichtenstein MattLichtenstein commented Nov 12, 2024

📜 Tickets

Jira ticket
Github issue

💡 Description

  • Hide the Desktop Bookmarks root folder (and nested Toolbar, Menu, and Unfiled) if it does not contain recursively any bookmarks (even when signed into a Mozilla Account)

📝 Discussion

  • The nested Toolbar, Menu, and Unfiled are now conditionally hidden from BookmarksViewController, LegacyBookmarkDetailPanel and EditBookmarkViewController

📦 Dependencies

📝 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)

Copy link
Collaborator

@FilippoZazzeroni FilippoZazzeroni left a comment

Choose a reason for hiding this comment

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

Some nit things 💪

recursiveAddSubFolders(folder, folders: &folders)
}
recursive: true).uponQueue(.main) { data in
self.profile.places.countBookmarksInTrees(folderGuids: BookmarkRoots.DesktopRoots.map { $0 })
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think to enhance readability by removing double nesting we can split this method in an async one like:

private func countBookmarksInTrees() async -> Int? {
}

And call it directly before the continuation since fetchFolder is an async method.

continuation.resume(returning: folders)
}
guard let rootFolder = data.successValue as? BookmarkFolderData,
let desktopBookmarksCount = bookmarksCountResult.successValue 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.

we can uplift this statement at the start of fetchFolder if we go for having a another method for counting bookmarks

@@ -32,6 +32,7 @@ import struct MozillaAppServices.VisitTransitionSet
public protocol BookmarksHandler {
func getRecentBookmarks(limit: UInt, completion: @escaping ([BookmarkItemData]) -> Void)
func getBookmarksTree(rootGUID: GUID, recursive: Bool) -> Deferred<Maybe<BookmarkNodeData?>>
func countBookmarksInTrees(folderGuids: [GUID]) -> Deferred<Maybe<Int>>
Copy link
Collaborator

Choose a reason for hiding this comment

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

i think we should remove Deferred from our code base since i guess it is legacy code. what do you think to refactor this either with an async method if possible otherwise a closure ? 👀

profile.places.countBookmarksInTrees(folderGuids: BookmarkRoots.DesktopRoots.map { $0 })
.uponQueue(.main) { bookmarksCountResult in
var desktopBookmarksCount: Int?
defer { continuation.resume(returning: desktopBookmarksCount) }
Copy link
Collaborator

Choose a reason for hiding this comment

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

i'd put the defer on multi line so it is clearly visible

defer {
  
}

let profile: Profile
let rootFolderGUID: String

func fetchFolders() async -> [Folder] {
let numDesktopBookmarks = await countDesktopBookmarks()
Copy link
Collaborator

Choose a reason for hiding this comment

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

🔝

}
}
}
}

private func recursiveAddSubFolders(_ folder: BookmarkFolderData,
folders: inout [Folder],
hasDesktopBookmarks: Bool = false,
Copy link
Collaborator

Choose a reason for hiding this comment

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

i'd remove the default value since we are passing it everywhere

Copy link
Collaborator

@FilippoZazzeroni FilippoZazzeroni left a comment

Choose a reason for hiding this comment

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

LGTM 🎉 just some nit things

@@ -199,6 +201,17 @@ public class RustPlaces: BookmarksHandler, HistoryMetadataObserver {
}
}

public func countBookmarksInTrees(folderGuids: [GUID], completion: @escaping (Result<Int, Error>) -> Void) {
withReader { connection in
Copy link
Collaborator

Choose a reason for hiding this comment

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

i'd think the reader needs to be stored inside a variable and check wether there was reader errors, because it could happen that there were connection error and callback provided to withReader will never be called. I assume that by reading the implementation of withReader

@@ -137,6 +138,7 @@ public class RustPlaces: BookmarksHandler, HistoryMetadataObserver {
return deferred
}

@discardableResult
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we should remove this following up the previous comment

@MattLichtenstein MattLichtenstein force-pushed the ml/FXIOS-9744_hide-desktop-bookmarks-folder branch from 73acc28 to 9a9658c Compare November 14, 2024 17:42
@mobiletest-ci-bot
Copy link

Messages
📖 Project coverage: 32.25%
📖 Edited 6 files
📖 Created 0 files

Client.app: Coverage: 30.17

File Coverage
BookmarksPanelViewModel.swift 82.59%
FolderHierarchyFetcher.swift 92.62%
LegacyBookmarkDetailPanel.swift 17.78% ⚠️

libStorage.a: Coverage: 55.99

File Coverage
RustPlaces.swift 76.01%

Generated by 🚫 Danger Swift against 9a9658c

@MattLichtenstein MattLichtenstein merged commit acbdac0 into main Nov 15, 2024
8 of 11 checks passed
@MattLichtenstein MattLichtenstein deleted the ml/FXIOS-9744_hide-desktop-bookmarks-folder branch November 15, 2024 14:25
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.

3 participants