-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Add FXIOS-9744 Hide desktop bookmarks folder #23074
Conversation
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.
Some nit things 💪
recursiveAddSubFolders(folder, folders: &folders) | ||
} | ||
recursive: true).uponQueue(.main) { data in | ||
self.profile.places.countBookmarksInTrees(folderGuids: BookmarkRoots.DesktopRoots.map { $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 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 } |
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.
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>> |
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 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) } |
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'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() |
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.
🔝
} | ||
} | ||
} | ||
} | ||
|
||
private func recursiveAddSubFolders(_ folder: BookmarkFolderData, | ||
folders: inout [Folder], | ||
hasDesktopBookmarks: Bool = false, |
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'd remove the default value since we are passing it everywhere
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.
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 |
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'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 |
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 think we should remove this following up the previous comment
73acc28
to
9a9658c
Compare
Client.app: Coverage: 30.17
libStorage.a: Coverage: 55.99
Generated by 🚫 Danger Swift against 9a9658c |
📜 Tickets
Jira ticket
Github issue
💡 Description
Desktop Bookmarks
root folder (and nestedToolbar
,Menu
, andUnfiled
) if it does not contain recursively any bookmarks (even when signed into a Mozilla Account)📝 Discussion
Toolbar
,Menu
, andUnfiled
are now conditionally hidden fromBookmarksViewController
,LegacyBookmarkDetailPanel
andEditBookmarkViewController
📦 Dependencies
📝 Checklist
You have to check all boxes before merging
@Mergifyio backport release/v120
)