mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 16:10:20 +00:00
Close all secondary windows on logout
This commit is contained in:
committed by
Stefan Ceriu
parent
deaa2727db
commit
891c3fffd4
@@ -793,6 +793,8 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationFlowCoordinatorDeleg
|
|||||||
fatalError("User session not setup")
|
fatalError("User session not setup")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
windowManager.closeAllAuxiliaryWindows()
|
||||||
|
|
||||||
showLoadingIndicator()
|
showLoadingIndicator()
|
||||||
|
|
||||||
stopSync(isBackgroundTask: false)
|
stopSync(isBackgroundTask: false)
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ struct Application: App {
|
|||||||
@UIApplicationDelegateAdaptor(AppDelegate.self) private var appDelegate
|
@UIApplicationDelegateAdaptor(AppDelegate.self) private var appDelegate
|
||||||
@Environment(\.openURL) private var openURL
|
@Environment(\.openURL) private var openURL
|
||||||
@Environment(\.openWindow) private var openWindow
|
@Environment(\.openWindow) private var openWindow
|
||||||
|
@Environment(\.dismissWindow) private var dismissWindow
|
||||||
|
|
||||||
private var appCoordinator: AppCoordinatorProtocol!
|
private var appCoordinator: AppCoordinatorProtocol!
|
||||||
|
|
||||||
@@ -51,7 +52,8 @@ struct Application: App {
|
|||||||
}
|
}
|
||||||
.task {
|
.task {
|
||||||
appCoordinator.start()
|
appCoordinator.start()
|
||||||
appCoordinator.windowManager.configure(with: openWindow)
|
appCoordinator.windowManager.configure(withOpenWinddowAction: openWindow,
|
||||||
|
dismissWindowAction: dismissWindow)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.handlesExternalEvents(matching: ["*"])
|
.handlesExternalEvents(matching: ["*"])
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ class WindowManager: SecureWindowManagerProtocol {
|
|||||||
private(set) var alternateWindow: UIWindow!
|
private(set) var alternateWindow: UIWindow!
|
||||||
|
|
||||||
private(set) var openWindowAction: OpenWindowAction!
|
private(set) var openWindowAction: OpenWindowAction!
|
||||||
|
private(set) var dismissWindowAction: DismissWindowAction!
|
||||||
|
|
||||||
var windows: [UIWindow] {
|
var windows: [UIWindow] {
|
||||||
[mainWindow, overlayWindow, globalSearchWindow, alternateWindow]
|
[mainWindow, overlayWindow, globalSearchWindow, alternateWindow]
|
||||||
@@ -58,8 +59,10 @@ class WindowManager: SecureWindowManagerProtocol {
|
|||||||
delegate?.windowManagerDidConfigureWindows(self)
|
delegate?.windowManagerDidConfigureWindows(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
func configure(with openWindowAction: OpenWindowAction) {
|
func configure(withOpenWinddowAction openWindowAction: OpenWindowAction,
|
||||||
|
dismissWindowAction: DismissWindowAction) {
|
||||||
self.openWindowAction = openWindowAction
|
self.openWindowAction = openWindowAction
|
||||||
|
self.dismissWindowAction = dismissWindowAction
|
||||||
}
|
}
|
||||||
|
|
||||||
func registerCoordinator(_ coordinator: CoordinatorProtocol, flowCoordinator: FlowCoordinatorProtocol?, forWindowType type: WindowManagerWindowType) {
|
func registerCoordinator(_ coordinator: CoordinatorProtocol, flowCoordinator: FlowCoordinatorProtocol?, forWindowType type: WindowManagerWindowType) {
|
||||||
@@ -67,6 +70,14 @@ class WindowManager: SecureWindowManagerProtocol {
|
|||||||
openWindowAction(value: type)
|
openWindowAction(value: type)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func closeAllAuxiliaryWindows() {
|
||||||
|
for key in coordinators.keys {
|
||||||
|
dismissWindowAction(value: key)
|
||||||
|
}
|
||||||
|
|
||||||
|
coordinators.removeAll()
|
||||||
|
}
|
||||||
|
|
||||||
func windowForType(_ type: WindowManagerWindowType) -> AnyView {
|
func windowForType(_ type: WindowManagerWindowType) -> AnyView {
|
||||||
guard let coordinator = coordinators[type]?.coordinator else {
|
guard let coordinator = coordinators[type]?.coordinator else {
|
||||||
return AnyView(InstantlyDismissingWindow())
|
return AnyView(InstantlyDismissingWindow())
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ protocol SecureWindowManagerProtocol: WindowManagerProtocol {
|
|||||||
/// Configures the window manager to operate on the supplied scene.
|
/// Configures the window manager to operate on the supplied scene.
|
||||||
func configure(with windowScene: UIWindowScene)
|
func configure(with windowScene: UIWindowScene)
|
||||||
|
|
||||||
func configure(with openWindowAction: OpenWindowAction)
|
func configure(withOpenWinddowAction openWindowAction: OpenWindowAction, dismissWindowAction: DismissWindowAction)
|
||||||
|
|
||||||
func handleRoute(_ appRoute: AppRoute, windowType: WindowManagerWindowType)
|
func handleRoute(_ appRoute: AppRoute, windowType: WindowManagerWindowType)
|
||||||
|
|
||||||
@@ -56,6 +56,8 @@ protocol WindowManagerProtocol: AnyObject, OrientationManagerProtocol {
|
|||||||
|
|
||||||
func registerCoordinator(_ coordinator: CoordinatorProtocol, flowCoordinator: FlowCoordinatorProtocol?, forWindowType type: WindowManagerWindowType)
|
func registerCoordinator(_ coordinator: CoordinatorProtocol, flowCoordinator: FlowCoordinatorProtocol?, forWindowType type: WindowManagerWindowType)
|
||||||
|
|
||||||
|
func closeAllAuxiliaryWindows()
|
||||||
|
|
||||||
/// Makes the global search window key. Used to get automatic text field focus.
|
/// Makes the global search window key. Used to get automatic text field focus.
|
||||||
func showGlobalSearch()
|
func showGlobalSearch()
|
||||||
|
|
||||||
|
|||||||
@@ -21399,6 +21399,41 @@ class WindowManagerMock: WindowManagerProtocol, @unchecked Sendable {
|
|||||||
}
|
}
|
||||||
registerCoordinatorFlowCoordinatorForWindowTypeClosure?(coordinator, flowCoordinator, type)
|
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
|
//MARK: - showGlobalSearch
|
||||||
|
|
||||||
var showGlobalSearchUnderlyingCallsCount = 0
|
var showGlobalSearchUnderlyingCallsCount = 0
|
||||||
|
|||||||
Reference in New Issue
Block a user