Do not show spinners or screenshots during refresh visits#177
Do not show spinners or screenshots during refresh visits#177pfeiffer wants to merge 1 commit intohotwired:mainfrom
Conversation
jayohms
left a comment
There was a problem hiding this comment.
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.
| 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.
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.
| 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.
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
| } | ||
|
|
||
| func visitWillStart(_ visit: Visit) { | ||
| guard !visit.isPageRefresh else { return } |
| 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.
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