From b411f6b64f3cd7016599e7f7fd47057fca4d7d2d Mon Sep 17 00:00:00 2001 From: Joe Masilotti Date: Thu, 29 Feb 2024 04:56:37 -0800 Subject: [PATCH] Fix when snapshot cache is cleared --- Source/Session/Session.swift | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/Source/Session/Session.swift b/Source/Session/Session.swift index f9ef2fc..0831b27 100644 --- a/Source/Session/Session.swift +++ b/Source/Session/Session.swift @@ -229,7 +229,15 @@ extension Session: VisitableDelegate { public func visitableViewWillAppear(_ visitable: Visitable) { guard let topmostVisit = self.topmostVisit, let currentVisit = self.currentVisit else { return } - if visitable === topmostVisit.visitable && visitable.visitableViewController.isMovingToParent { + if isSnapshotCacheStale { + clearSnapshotCache() + isSnapshotCacheStale = false + } + + if isShowingStaleContent { + reload() + isShowingStaleContent = false + } else if visitable === topmostVisit.visitable && visitable.visitableViewController.isMovingToParent { // Back swipe gesture canceled if topmostVisit.state == .completed { currentVisit.cancel() @@ -242,12 +250,6 @@ extension Session: VisitableDelegate { } else if visitable !== topmostVisit.visitable { // Navigating backward visit(visitable, action: .restore) - } else if isShowingStaleContent { - reload() - isShowingStaleContent = false - } else if isSnapshotCacheStale { - clearSnapshotCache() - isSnapshotCacheStale = false } }