Skip to content

Commit

Permalink
Revert implementation changes
Browse files Browse the repository at this point in the history
Since [#571][] has shipped after this work was initially
proposed, the implementation changes aren't necessary for the tests to
pass.

This change reverts the changes but retains the more thorough test
coverage.

[#571]: #571
  • Loading branch information
seanpdoyle committed Jul 16, 2022
1 parent f542cd0 commit 4baaa87
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/core/drive/navigator.ts
Expand Up @@ -110,7 +110,7 @@ export class Navigator {
if (fetchResponse.serverError) {
await this.view.renderError(snapshot, this.currentVisit)
} else {
await this.view.renderPage(snapshot, this.currentVisit || null, false, true)
await this.view.renderPage(snapshot, false, true, this.currentVisit)
}
this.view.scrollToTop()
this.view.clearSnapshotCache()
Expand Down
7 changes: 5 additions & 2 deletions src/core/drive/page_view.ts
Expand Up @@ -15,10 +15,13 @@ type PageViewRenderer = PageRenderer | ErrorRenderer
export class PageView extends View<Element, PageSnapshot, PageViewRenderer, PageViewDelegate> {
readonly snapshotCache = new SnapshotCache(10)
lastRenderedLocation = new URL(location.href)
forceReloaded = false

renderPage(snapshot: PageSnapshot, visit: Visit | null, isPreview = false, willRender = true) {
renderPage(snapshot: PageSnapshot, isPreview = false, willRender = true, visit?: Visit) {
const renderer = new PageRenderer(this.snapshot, snapshot, isPreview, willRender)
if (renderer.shouldRender) {
if (!renderer.shouldRender) {
this.forceReloaded = true
} else {
visit?.changeHistory()
}
return this.render(renderer)
Expand Down
10 changes: 5 additions & 5 deletions src/core/drive/visit.ts
Expand Up @@ -228,8 +228,7 @@ export class Visit implements FetchRequestDelegate {
this.cacheSnapshot()
if (this.view.renderPromise) await this.view.renderPromise
if (isSuccessful(statusCode) && responseHTML != null) {
await this.view.renderPage(PageSnapshot.fromHTMLString(responseHTML), this, false, this.willRender)
this.performScroll()
await this.view.renderPage(PageSnapshot.fromHTMLString(responseHTML), false, this.willRender, this)
this.adapter.visitRendered(this)
this.complete()
} else {
Expand Down Expand Up @@ -271,8 +270,7 @@ export class Visit implements FetchRequestDelegate {
this.adapter.visitRendered(this)
} else {
if (this.view.renderPromise) await this.view.renderPromise
await this.view.renderPage(snapshot, this, isPreview, this.willRender)
this.performScroll()
await this.view.renderPage(snapshot, isPreview, this.willRender, this)
this.adapter.visitRendered(this)
if (!isPreview) {
this.complete()
Expand All @@ -297,7 +295,6 @@ export class Visit implements FetchRequestDelegate {
if (this.isSamePage) {
this.render(async () => {
this.cacheSnapshot()
this.performScroll()
this.adapter.visitRendered(this)
})
}
Expand Down Expand Up @@ -432,6 +429,9 @@ export class Visit implements FetchRequestDelegate {
})
await callback()
delete this.frame
if (!this.view.forceReloaded) {
this.performScroll()
}
}

cancelRender() {
Expand Down

0 comments on commit 4baaa87

Please sign in to comment.