Skip to content

Commit

Permalink
Dismiss push stack bug (#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
SwiftfulThinking committed Jun 6, 2024
1 parent c9c536b commit 02a6e29
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions Sources/SwiftfulRouting/Core/RouterView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -517,15 +517,18 @@ extension RouterViewInternal {

var screensToDismiss: [AnyRoute] = []
var didFindCurrentScreen: Bool = false
var newRootScreen: AnyRoute? = currentRouteArray.first

// All presented screens, first screen being the highest
let presentedRouteArrayReversed = currentRouteArray.filter({ $0.isPresented }).reversed()
var newRootScreen: AnyRoute? = presentedRouteArrayReversed.last

// Find all screens on current stack that are ahead of current screen that are .push & isPresented
for route in currentRouteArray.filter({ $0.isPresented }).reversed() {
for route in presentedRouteArrayReversed {
if route.segue == .push {
screensToDismiss.append(route)
}
if route.id == self.route.id {

if route.id == self.route.id || route == presentedRouteArrayReversed.last {
didFindCurrentScreen = true
}

Expand Down

0 comments on commit 02a6e29

Please sign in to comment.