mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:55:59 +00:00
Fix navigationStackCoordinator getting torn down when being reset on … (#613)
* Fix navigationStackCoordinator getting torn down when being reset on the navigationSplitCoordinator, added unit tests for it * Guard against using the same coordinator more than once
This commit is contained in:
@@ -138,6 +138,10 @@ class NavigationSplitCoordinator: CoordinatorProtocol, ObservableObject, CustomS
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if sidebarModule?.coordinator === coordinator {
|
||||||
|
fatalError("Cannot use the same coordinator more than once")
|
||||||
|
}
|
||||||
|
|
||||||
sidebarModule = NavigationModule(coordinator, dismissalCallback: dismissalCallback)
|
sidebarModule = NavigationModule(coordinator, dismissalCallback: dismissalCallback)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -151,6 +155,10 @@ class NavigationSplitCoordinator: CoordinatorProtocol, ObservableObject, CustomS
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if detailModule?.coordinator === coordinator {
|
||||||
|
fatalError("Cannot use the same coordinator more than once")
|
||||||
|
}
|
||||||
|
|
||||||
detailModule = NavigationModule(coordinator, dismissalCallback: dismissalCallback)
|
detailModule = NavigationModule(coordinator, dismissalCallback: dismissalCallback)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -164,6 +172,10 @@ class NavigationSplitCoordinator: CoordinatorProtocol, ObservableObject, CustomS
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if sheetModule?.coordinator === coordinator {
|
||||||
|
fatalError("Cannot use the same coordinator more than once")
|
||||||
|
}
|
||||||
|
|
||||||
sheetModule = NavigationModule(coordinator, dismissalCallback: dismissalCallback)
|
sheetModule = NavigationModule(coordinator, dismissalCallback: dismissalCallback)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -177,6 +189,10 @@ class NavigationSplitCoordinator: CoordinatorProtocol, ObservableObject, CustomS
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if fullScreenCoverModule?.coordinator === coordinator {
|
||||||
|
fatalError("Cannot use the same coordinator more than once")
|
||||||
|
}
|
||||||
|
|
||||||
fullScreenCoverModule = NavigationModule(coordinator, dismissalCallback: dismissalCallback)
|
fullScreenCoverModule = NavigationModule(coordinator, dismissalCallback: dismissalCallback)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -509,6 +525,10 @@ class NavigationStackCoordinator: ObservableObject, CoordinatorProtocol, CustomS
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if rootModule?.coordinator === coordinator {
|
||||||
|
fatalError("Cannot use the same coordinator more than once")
|
||||||
|
}
|
||||||
|
|
||||||
popToRoot(animated: false)
|
popToRoot(animated: false)
|
||||||
|
|
||||||
rootModule = NavigationModule(coordinator, dismissalCallback: dismissalCallback)
|
rootModule = NavigationModule(coordinator, dismissalCallback: dismissalCallback)
|
||||||
@@ -565,6 +585,10 @@ class NavigationStackCoordinator: ObservableObject, CoordinatorProtocol, CustomS
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if sheetModule?.coordinator === coordinator {
|
||||||
|
fatalError("Cannot use the same coordinator more than once")
|
||||||
|
}
|
||||||
|
|
||||||
sheetModule = NavigationModule(coordinator, dismissalCallback: dismissalCallback)
|
sheetModule = NavigationModule(coordinator, dismissalCallback: dismissalCallback)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -584,6 +608,10 @@ class NavigationStackCoordinator: ObservableObject, CoordinatorProtocol, CustomS
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if fullScreenCoverModule?.coordinator === coordinator {
|
||||||
|
fatalError("Cannot use the same coordinator more than once")
|
||||||
|
}
|
||||||
|
|
||||||
fullScreenCoverModule = NavigationModule(coordinator, dismissalCallback: dismissalCallback)
|
fullScreenCoverModule = NavigationModule(coordinator, dismissalCallback: dismissalCallback)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -168,8 +168,7 @@ class UserSessionFlowCoordinator: CoordinatorProtocol {
|
|||||||
emojiProvider: emojiProvider)
|
emojiProvider: emojiProvider)
|
||||||
let coordinator = RoomScreenCoordinator(parameters: parameters)
|
let coordinator = RoomScreenCoordinator(parameters: parameters)
|
||||||
|
|
||||||
detailNavigationStackCoordinator.setRootCoordinator(coordinator)
|
detailNavigationStackCoordinator.setRootCoordinator(coordinator) { [weak self, roomIdentifier] in
|
||||||
navigationSplitCoordinator.setDetailCoordinator(detailNavigationStackCoordinator) { [weak self, roomIdentifier] in
|
|
||||||
guard let self else { return }
|
guard let self else { return }
|
||||||
|
|
||||||
// Move the state machine to no room selected if the room currently being dimissed
|
// Move the state machine to no room selected if the room currently being dimissed
|
||||||
@@ -180,6 +179,10 @@ class UserSessionFlowCoordinator: CoordinatorProtocol {
|
|||||||
self.detailNavigationStackCoordinator.setRootCoordinator(nil)
|
self.detailNavigationStackCoordinator.setRootCoordinator(nil)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if navigationSplitCoordinator.detailCoordinator == nil {
|
||||||
|
navigationSplitCoordinator.setDetailCoordinator(detailNavigationStackCoordinator)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -259,9 +259,13 @@ class NavigationSplitCoordinatorTests: XCTestCase {
|
|||||||
// MARK: - Private
|
// MARK: - Private
|
||||||
|
|
||||||
private func assertCoordinatorsEqual(_ lhs: CoordinatorProtocol?, _ rhs: CoordinatorProtocol?) {
|
private func assertCoordinatorsEqual(_ lhs: CoordinatorProtocol?, _ rhs: CoordinatorProtocol?) {
|
||||||
|
if lhs == nil, rhs == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
guard let lhs = lhs as? SomeTestCoordinator,
|
guard let lhs = lhs as? SomeTestCoordinator,
|
||||||
let rhs = rhs as? SomeTestCoordinator else {
|
let rhs = rhs as? SomeTestCoordinator else {
|
||||||
XCTFail("Coordinators are not the same")
|
XCTFail("Coordinators are not the same: \(String(describing: lhs)) != \(String(describing: rhs))")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
Fix broken split layout room navigation
|
||||||
Reference in New Issue
Block a user