-
Notifications
You must be signed in to change notification settings - Fork 86
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
Do not show spinners or screenshots during refresh visits #177
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.
Thank you @pfeiffer! This looks like a straightforward, elegant solution. I left some comments for improvements that we'll need before merging. If you're able to get to it soon, that'd be awesome — otherwise I can propose another PR with the corresponding changes.
@@ -116,7 +119,7 @@ | |||
|
|||
visitStarted(visit) { | |||
this.currentVisit = visit | |||
this.postMessage("visitStarted", { identifier: visit.identifier, hasCachedSnapshot: visit.hasCachedSnapshot() }) | |||
this.postMessage("visitStarted", { identifier: visit.identifier, hasCachedSnapshot: visit.hasCachedSnapshot(), isPageRefresh: visit.isPageRefresh }) |
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.
This doesn't look compatible with Turbo 7 without page refresh support. The mobile adapters need to remain compatible with Turbolinks 5, Turbo 7, and Turbo 8.
@@ -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) { |
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.
In the corresponding Android PR, I found that the approach doesn't work immediately after a page cold boot, because this.currentVisit
hasn't been set yet. Using Turbo.navigator.location?.href === location.href
works in all circumstances, though. https://github.com/hotwired/turbo-android/pull/292/files#diff-aafcc0efe91961803491a50ad6158bc1b6416c69417325a6fa5d1bc50a2be45cR105
@@ -164,12 +164,16 @@ extension Session: VisitDelegate { | |||
} | |||
|
|||
func visitWillStart(_ visit: Visit) { | |||
guard !visit.isPageRefresh 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.
Nice 👏
if (Turbo.navigator.locationWithActionIsSamePage(location, options.action)) { | ||
Turbo.navigator.view.scrollToAnchorFromLocation(location) | ||
return | ||
} else if (this.currentVisit?.location?.href === location.href) { |
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 prefer that we changed the conditional logic to look like the modified Android adapter logic with comments and logging: https://github.com/hotwired/turbo-android/pull/292/files#diff-aafcc0efe91961803491a50ad6158bc1b6416c69417325a6fa5d1bc50a2be45cL101-L108
It's more clear and removes a conditional that was necessary during a transitional Turbo 7 rollout period.
Closed in favor of #178 |
Fixes #175, #136 and #160.
Building on the change in #160 by @afcapel, this tracks if a visit is a page refresh and skips showing screenshot and activity spinners. The WebView is still activated and can be scrolled during the refresh visits as expected.
Previously the WebView would be 'blanked', become unresponsive and spinners would be shown.
The behavior during refreshes after this change (no spinners or blank webview and the view is still scrollable and active):
MorphAfter.mov