Skip to content

Commit

Permalink
Use defer to nil out the previous visit.
Browse files Browse the repository at this point in the history
  • Loading branch information
svara committed Mar 4, 2024
1 parent ef3b9fa commit 54b1cd8
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions Source/Session/Session.swift
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,9 @@ extension Session: VisitDelegate {

extension Session: VisitableDelegate {
public func visitableViewWillAppear(_ visitable: Visitable) {
let lastDisappearingVisit = self.previosVisit
self.previosVisit = nil
defer {
previosVisit = nil
}

guard let topmostVisit = self.topmostVisit, let currentVisit = self.currentVisit else { return }

Expand All @@ -229,8 +230,11 @@ extension Session: VisitableDelegate {
} else if visitable === currentVisit.visitable && currentVisit.state == .started {
// Navigating forward - complete navigation early
completeNavigationForCurrentVisit()
} else if visitable !== topmostVisit.visitable || visitable === previosVisit?.visitable {
// Navigating backward
} else if visitable !== topmostVisit.visitable {
// Navigating backward from a web view screen to a web view screen.
visit(visitable, action: .restore)
} else if visitable === previosVisit?.visitable {
// Navigating backward from a native to a web view screen.
visit(visitable, action: .restore)
}
}
Expand Down

0 comments on commit 54b1cd8

Please sign in to comment.