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-10928 [Bookmarks Evolution] Last Viewed Bookmarks Folder Persists Across App Sessions #24047

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

DanielDervishi
Copy link
Collaborator

📜 Tickets

Jira ticket
Github issue

💡 Description

After entering a bookmarks folder in the as you view the bookmarks panel, you can now close the app and will be shown the same folder upon re-entering the bookmarks panel

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

@DanielDervishi DanielDervishi requested a review from a team as a code owner January 8, 2025 18:56
treeRootNode: bookmarkTreeRoot),
!path.isEmpty else {return}
path.removeFirst()
path.forEach { el in
Copy link
Contributor

Choose a reason for hiding this comment

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

What does el stands for? Can we have another name for this variable?

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, when this forEach is called, what does it look like if we have a lot of nested folders? Animations are set to false, so I guess to the user it's as if we magically appeared inside the nested folder?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yep, the behaviour is the same as if we were to close the library panel, and re-open it without restarting the app. From what I understood this was the behaviour we were trying to mimic. If we would like to have animations active I can do that as well.

Copy link
Contributor

Choose a reason for hiding this comment

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

Without animation is good! Just wanted to confirm I understood properly, thank you!

@@ -135,12 +135,55 @@ class LibraryCoordinator: BaseCoordinator,
if isBookmarkRefactorEnabled {
(navigationController.topViewController as? BookmarksViewController)?
.bookmarkCoordinatorDelegate = bookmarksCoordinator
if let recentFolderGUID = profile.prefs.stringForKey(PrefsKeys.LastViewedBookmarkFolder) {
Copy link
Contributor

Choose a reason for hiding this comment

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

So I understand why this is easier to be done here, but IMO we shouldn't have any business logic inside the coordinator. Coordinators role should be as simple as possible, and only hold navigation logic (no decision making apart from feature flags, and no database/network calls). Coordinator mostly creates VC, pass down dependencies, hold child coordinators, start flows, but they get told which navigation flow to start since they are not responsible per say of anything. Decision making normally falls into VC or other managers of some sort.

Now, what does this mean here? Well, IMO that some changes are needed 🙈 Maybe a way to keep this simple is to have a bookmarks state manager of some sort? The LibraryViewController could be responsible to fetch the path, then start the proper coordinator flow (through a parameter on the start(panelType:) function? Just trying to throw in some ideas, let me know if you have a better idea!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Gotcha, I'll look into a different way of doing this that keeps the business logic out of the coordinators 😃 👍

private func populateBookmarksNavigationController(currentFolderGUID: String,
bookmarksCoordinator: BookmarksCoordinator,
completion: @escaping () -> Void) {
profile.places.getBookmarksTree(rootGUID: BookmarkRoots.MobileFolderGUID,
Copy link
Collaborator

Choose a reason for hiding this comment

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

We are going to need to account for potentially loading into one of the desktop folders, so we'll need to pass in BookmarkRoots.RootGUID instead of BookmarksRoots.MobileFolderGUID. This gets you most of the way there, but because of the way the folder structure is set up in the places db, things get a little tricky. The internal db folder structure looks something like this:

root
├ menu
├ toolbar
├ unfiled
├ mobile
│ ├ Example folder 1
│ ├ Example folder 2
│ ├ Example folder n

As you can see, the places db has no concept of the "Desktop Bookmarks" folder that, in the UI, parents the 3 desktop folders (menu, toolbar, and unfiled). That is something we create just for a better UX. This means if we restore the app to:

  • Any of the 3 desktop folders: Clicking "<" will take us to the root
  • Desktop Bookmarks: well, it will never find this guid because it doesn't exist in the db

The first one, not so bad, we can live with that, the second one... well the library panel probably won't load.

I haven't done much investigation into what a proper fix would look like, so I am not sure the level of effort, but if it is a lot, as a backup I think we can just avoid the really unhappy path and hardcode it such that if a user is restoring into the "Desktop Bookmarks" folder, we just load them back to the "mobile" folder. What do you think?

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