Skip to content

Commit

Permalink
Fix issue where snapshot cache doesn't get cleared
Browse files Browse the repository at this point in the history
  • Loading branch information
joemasilotti committed Feb 26, 2024
1 parent cbb7356 commit 0dbf9d9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion Source/Session/Session.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ public class Session: NSObject {

public let webView: WKWebView
public var pathConfiguration: PathConfiguration?


var needsCacheClearing = false

private lazy var bridge = WebViewBridge(webView: webView)
private var initialized = false
private var refreshing = false
Expand Down Expand Up @@ -215,6 +217,11 @@ extension Session: VisitableDelegate {
public func visitableViewWillAppear(_ visitable: Visitable) {
guard let topmostVisit = self.topmostVisit, let currentVisit = self.currentVisit else { return }

if needsCacheClearing {
clearSnapshotCache()
needsCacheClearing = false
}

if visitable === topmostVisit.visitable && visitable.visitableViewController.isMovingToParent {
// Back swipe gesture canceled
if topmostVisit.state == .completed {
Expand Down
2 changes: 1 addition & 1 deletion Source/Turbo Navigator/TurboNavigator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ extension TurboNavigator: SessionDelegate {

public func sessionDidFinishFormSubmission(_ session: Session) {
if session == modalSession {
self.session.clearSnapshotCache()
self.session.needsCacheClearing = true
}
if let url = session.topmostVisitable?.visitableURL {
delegate.formSubmissionDidFinish(at: url)
Expand Down

0 comments on commit 0dbf9d9

Please sign in to comment.