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
Improve state restoration performance #4531
Conversation
@@ -21,6 +21,78 @@ final class NavigationStateController: NSObject { | |||
private typealias Presentation = ViewController.Presentation | |||
private typealias Info = ViewController.Info | |||
|
|||
/// Finds the topmost article from persisted NavigationState and pushes it onto navigationController | |||
@objc func restoreLastArticle(for navigationController: UINavigationController, in moc: NSManagedObjectContext, with theme: Theme, completion: @escaping () -> Void) { | |||
guard let tabBarController = navigationController.viewControllers.first as? UITabBarController else { |
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 this warning can be alleviated with:
guard navigationController.viewControllers.first is UITabBarController else { ...
(Also very cool to see the Xcode Cloud warnings propagating up to the code review layer here in GitHub!)
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.
return childArticleViewController ?? articleViewController | ||
} | ||
|
||
/// Attempts to restore user's entire heirarchy, included presented modal navigation stacks. Currently not in use in preference of restoreLastArticle to improve loading times. |
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.
@tonisevener Super minor: typos heirarchy → hierarchy, included → including.
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.
Ah sorry about that, this is fixed (also in other places I found).
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.
Awesome - working as expected for me so far. Hoping it makes an impact for our users!
Phabricator:
https://phabricator.wikimedia.org/T337073
Notes
This PR simplifies state restoration to only the user's last read article, to reduce the chance of prolonged state restoration times upon launch. It also fixes a couple of bugs that originally caused a situation where the user was stuck in a Reading List Detail modal state upon restoration. Test steps for each commit are below.
6485b92 - This fixed a bug where there was a missing close button upon state restoration to a modal Reading List Detail screen. This area of code isn't actually hit anymore due to later commits in this PR, but I decided to fix it anyway in case we bring full view controller hierarchy restoration back in the future. You must git checkout this SHA if you want to test it. Test steps for this are:
main
.92c22db and 0b9740a - This prevents pushing on an article from a Reading List Detail modal. Instead it dismisses the modal upon cell tap, then pushes on the article onto the stack below. Test steps are:
b4c0bcf - This is the bigger change with simplifying state restoration. I kept the way we persist navigation state as-is, but now upon state restoration, this only seeks out the top-most article, and pushes that onto the root navigation stack.
Marking as Draft while we confirm this direction with product / design.