-
Notifications
You must be signed in to change notification settings - Fork 91
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 snapshot cache issue #173
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -113,7 +113,7 @@ extension TurboNavigator: SessionDelegate { | |
|
||
public func sessionDidFinishFormSubmission(_ session: Session) { | ||
if session == modalSession { | ||
self.session.clearSnapshotCache() | ||
self.session.perform(#selector(Session.clearSnapshotCache), with: nil, afterDelay: 1) | ||
Comment on lines
115
to
+116
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you moved this logic to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, that doesn't seem to do the trick. From what I can gather, we need to delay the call to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tested the demo app thoroughly and only once hit a javascript error when calling I was able to find a solution though. Whether it's elegant is up for debate :)
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This does look like a better solution to me and removes the timing implications. @joemasilotti if you can merge up the latest from There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @joemasilotti The PR looks great. @jayohms The current flag name is still There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jayohms I've started reviewing the PR. The solution looks solid, but I need to spend some more time familiarizing myself with caching in general. |
||
} | ||
if let url = session.topmostVisitable?.visitableURL { | ||
delegate.formSubmissionDidFinish(at: url) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -103,6 +103,9 @@ | |
if (Turbo.navigator.locationWithActionIsSamePage(location, options.action)) { | ||
Turbo.navigator.view.scrollToAnchorFromLocation(location) | ||
return | ||
} else if (this.currentVisit?.location?.href === location.href) { | ||
this.visitLocationWithOptionsAndRestorationIdentifier(location, options, Turbo.navigator.restorationIdentifier) | ||
return | ||
Comment on lines
+106
to
+108
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like this also fixes this for Turbo 8, which is great: #160 I'd preferably like to see something close to the Android implementation, where we call back to the native session, so we can add proper logging around it, like this: hotwired/turbo-android#292 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I cherry-picked that commit directly from the PR! |
||
} | ||
} | ||
|
||
|
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.
Is this preventing a visit in the modal session? Was a visit happening both in the modal session and the default session?
Could this break apps that don't have a two-session setup?
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.
Yep, a visit was happening in the modal session and then again in the default session.
I disabled the modal path configuration and everything seems to work as expected when navigating back.
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.
Interesting, why would
visitableViewWillAppear()
be called in the modalSession
if it's being dismissed? Seems like the root issue is at a higher layer?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 was not able to reproduce this, but the additional code is needed for the following reason.
When a new visit is proposed via
advance
, a new view controller is created. The new view controller is in the process of being added to the navigation controller, thusisMovingToParent
istrue
.