Close all secondary windows on logout
This commit is contained in:
committed by
Stefan Ceriu
parent
806767be7f
commit
b034fffb1f
@@ -793,6 +793,8 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationFlowCoordinatorDeleg
|
||||
fatalError("User session not setup")
|
||||
}
|
||||
|
||||
windowManager.closeAllAuxiliaryWindows()
|
||||
|
||||
showLoadingIndicator()
|
||||
|
||||
stopSync(isBackgroundTask: false)
|
||||
|
||||
@@ -13,6 +13,7 @@ struct Application: App {
|
||||
@UIApplicationDelegateAdaptor(AppDelegate.self) private var appDelegate
|
||||
@Environment(\.openURL) private var openURL
|
||||
@Environment(\.openWindow) private var openWindow
|
||||
@Environment(\.dismissWindow) private var dismissWindow
|
||||
|
||||
private var appCoordinator: AppCoordinatorProtocol!
|
||||
|
||||
@@ -51,7 +52,8 @@ struct Application: App {
|
||||
}
|
||||
.task {
|
||||
appCoordinator.start()
|
||||
appCoordinator.windowManager.configure(with: openWindow)
|
||||
appCoordinator.windowManager.configure(withOpenWinddowAction: openWindow,
|
||||
dismissWindowAction: dismissWindow)
|
||||
}
|
||||
}
|
||||
.handlesExternalEvents(matching: ["*"])
|
||||
|
||||
@@ -20,6 +20,7 @@ class WindowManager: SecureWindowManagerProtocol {
|
||||
private(set) var alternateWindow: UIWindow!
|
||||
|
||||
private(set) var openWindowAction: OpenWindowAction!
|
||||
private(set) var dismissWindowAction: DismissWindowAction!
|
||||
|
||||
var windows: [UIWindow] {
|
||||
[mainWindow, overlayWindow, globalSearchWindow, alternateWindow]
|
||||
@@ -58,8 +59,10 @@ class WindowManager: SecureWindowManagerProtocol {
|
||||
delegate?.windowManagerDidConfigureWindows(self)
|
||||
}
|
||||
|
||||
func configure(with openWindowAction: OpenWindowAction) {
|
||||
func configure(withOpenWinddowAction openWindowAction: OpenWindowAction,
|
||||
dismissWindowAction: DismissWindowAction) {
|
||||
self.openWindowAction = openWindowAction
|
||||
self.dismissWindowAction = dismissWindowAction
|
||||
}
|
||||
|
||||
func registerCoordinator(_ coordinator: CoordinatorProtocol, flowCoordinator: FlowCoordinatorProtocol?, forWindowType type: WindowManagerWindowType) {
|
||||
@@ -67,6 +70,14 @@ class WindowManager: SecureWindowManagerProtocol {
|
||||
openWindowAction(value: type)
|
||||
}
|
||||
|
||||
func closeAllAuxiliaryWindows() {
|
||||
for key in coordinators.keys {
|
||||
dismissWindowAction(value: key)
|
||||
}
|
||||
|
||||
coordinators.removeAll()
|
||||
}
|
||||
|
||||
func windowForType(_ type: WindowManagerWindowType) -> AnyView {
|
||||
guard let coordinator = coordinators[type]?.coordinator else {
|
||||
return AnyView(InstantlyDismissingWindow())
|
||||
|
||||
@@ -25,7 +25,7 @@ protocol SecureWindowManagerProtocol: WindowManagerProtocol {
|
||||
/// Configures the window manager to operate on the supplied scene.
|
||||
func configure(with windowScene: UIWindowScene)
|
||||
|
||||
func configure(with openWindowAction: OpenWindowAction)
|
||||
func configure(withOpenWinddowAction openWindowAction: OpenWindowAction, dismissWindowAction: DismissWindowAction)
|
||||
|
||||
func handleRoute(_ appRoute: AppRoute, windowType: WindowManagerWindowType)
|
||||
|
||||
@@ -56,6 +56,8 @@ protocol WindowManagerProtocol: AnyObject, OrientationManagerProtocol {
|
||||
|
||||
func registerCoordinator(_ coordinator: CoordinatorProtocol, flowCoordinator: FlowCoordinatorProtocol?, forWindowType type: WindowManagerWindowType)
|
||||
|
||||
func closeAllAuxiliaryWindows()
|
||||
|
||||
/// Makes the global search window key. Used to get automatic text field focus.
|
||||
func showGlobalSearch()
|
||||
|
||||
|
||||
@@ -21399,6 +21399,41 @@ class WindowManagerMock: WindowManagerProtocol, @unchecked Sendable {
|
||||
}
|
||||
registerCoordinatorFlowCoordinatorForWindowTypeClosure?(coordinator, flowCoordinator, type)
|
||||
}
|
||||
//MARK: - closeAllAuxiliaryWindows
|
||||
|
||||
var closeAllAuxiliaryWindowsUnderlyingCallsCount = 0
|
||||
var closeAllAuxiliaryWindowsCallsCount: Int {
|
||||
get {
|
||||
if Thread.isMainThread {
|
||||
return closeAllAuxiliaryWindowsUnderlyingCallsCount
|
||||
} else {
|
||||
var returnValue: Int? = nil
|
||||
DispatchQueue.main.sync {
|
||||
returnValue = closeAllAuxiliaryWindowsUnderlyingCallsCount
|
||||
}
|
||||
|
||||
return returnValue!
|
||||
}
|
||||
}
|
||||
set {
|
||||
if Thread.isMainThread {
|
||||
closeAllAuxiliaryWindowsUnderlyingCallsCount = newValue
|
||||
} else {
|
||||
DispatchQueue.main.sync {
|
||||
closeAllAuxiliaryWindowsUnderlyingCallsCount = newValue
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
var closeAllAuxiliaryWindowsCalled: Bool {
|
||||
return closeAllAuxiliaryWindowsCallsCount > 0
|
||||
}
|
||||
var closeAllAuxiliaryWindowsClosure: (() -> Void)?
|
||||
|
||||
func closeAllAuxiliaryWindows() {
|
||||
closeAllAuxiliaryWindowsCallsCount += 1
|
||||
closeAllAuxiliaryWindowsClosure?()
|
||||
}
|
||||
//MARK: - showGlobalSearch
|
||||
|
||||
var showGlobalSearchUnderlyingCallsCount = 0
|
||||
|
||||
Reference in New Issue
Block a user