-
Notifications
You must be signed in to change notification settings - Fork 88
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
Fix refresh behavior #220
Fix refresh behavior #220
Conversation
} | ||
|
||
private func refreshIfTopViewControllerIsVisitable(from stack: NavigationStackType) { | ||
if let navControllerTopmostVisitable = navController(for: stack).topViewController as? Visitable { |
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 should discuss the best way to pass this refresh message to a non-Visitable view controller.
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.
As you mentioned on the call, leveraging the PathConfigurationIdentifiable
protocol is an option here.
switch navigationStack { | ||
case .main: session.reload() |
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't use session.reload() because topmostVisitable does not change when a view controller is popped (or dismissed) programmatically. For example:
- Propose visit to URL "/one"
- Visit completes, session.topmostVisitable = "one"
- Propose visit to URL "/two"
- Visit completes, session.topmostVisitable = "two"
- Propose visit to URL "/refresh_historical_location" with presentation: refresh
- Visitable with visitableURL = "/two" is popped.
- session.reload() is called, which reloads the topmost visitable ("/two" set during step 4).
cfa9487
to
23d5ca9
Compare
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.
Good catch @olivaresf!
I really like the tests 👌
} | ||
|
||
private func refreshIfTopViewControllerIsVisitable(from stack: NavigationStackType) { | ||
if let navControllerTopmostVisitable = navController(for: stack).topViewController as? Visitable { |
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.
As you mentioned on the call, leveraging the PathConfigurationIdentifiable
protocol is an option here.
While testing, I found that when a visit with a refresh presentation is proposed,
TurboNavigatorHierarchyController
will correctly pop (or dismiss) and then ask the session to reload. However, the session does not know that the topmost visitable changed, so a reload will end up reloading the last successfully loaded visit – the visitable that was just popped (or dismissed).