mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-24 18:59:36 +00:00
End the web call when its account's screens go away
Signing out, a soft logout or clearing the cache replace the session's screens, which stops the tab coordinator. Its stop() only tore down its tabs, so a call screen in its overlay (and anything in its sheet or full-screen cover) was never stopped: the web call stayed ongoing and, with the missed-while-busy rule, every later call showed as missed until the app restarted. stop() now also tears down its sheet, full-screen cover and overlay, as the stack and split coordinators already do for what they present.
This commit is contained in:
@@ -273,9 +273,11 @@ import SwiftUI
|
||||
|
||||
// MARK: - CoordinatorProtocol
|
||||
|
||||
/// No idea if this is particuarly needed for the TabView but we do this for the NavigationStackCoordinator and NavigationSplitCoordinator so it
|
||||
/// doesn't seem to harm to also do it here.
|
||||
func stop() {
|
||||
sheetModule?.tearDown()
|
||||
fullScreenCoverModule?.tearDown()
|
||||
overlayModule?.tearDown()
|
||||
|
||||
tabModules.forEach { $0.module.tearDown() }
|
||||
}
|
||||
|
||||
|
||||
@@ -116,6 +116,7 @@ extension JoinedRoomProxyMock {
|
||||
unbanUserReturnValue = .success(())
|
||||
|
||||
let widgetDriver = ElementCallWidgetDriverMock()
|
||||
widgetDriver.widgetID = UUID().uuidString
|
||||
widgetDriver.messagePublisher = .init()
|
||||
widgetDriver.actions = PassthroughSubject().eraseToAnyPublisher()
|
||||
|
||||
|
||||
@@ -171,6 +171,28 @@ struct NavigationSplitCoordinatorTests {
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Stopping
|
||||
|
||||
@Test
|
||||
func stoppingTearsDownTheSidebarDetailAndEverythingPresentedOverThem() {
|
||||
let sidebarCoordinator = StopTrackingCoordinator()
|
||||
let detailCoordinator = StopTrackingCoordinator()
|
||||
let sheetCoordinator = StopTrackingCoordinator()
|
||||
let fullScreenCoverCoordinator = StopTrackingCoordinator()
|
||||
|
||||
navigationSplitCoordinator.setSidebarCoordinator(sidebarCoordinator)
|
||||
navigationSplitCoordinator.setDetailCoordinator(detailCoordinator)
|
||||
navigationSplitCoordinator.setSheetCoordinator(sheetCoordinator)
|
||||
navigationSplitCoordinator.setFullScreenCoverCoordinator(fullScreenCoverCoordinator)
|
||||
|
||||
navigationSplitCoordinator.stop()
|
||||
|
||||
#expect(sidebarCoordinator.didStop)
|
||||
#expect(detailCoordinator.didStop)
|
||||
#expect(sheetCoordinator.didStop)
|
||||
#expect(fullScreenCoverCoordinator.didStop)
|
||||
}
|
||||
|
||||
// MARK: - Advanced
|
||||
|
||||
@Test
|
||||
@@ -348,3 +370,11 @@ private func assertCoordinatorsEqual(_ lhs: CoordinatorProtocol?, _ rhs: Coordin
|
||||
private class SomeTestCoordinator: CoordinatorProtocol {
|
||||
let id = UUID()
|
||||
}
|
||||
|
||||
private class StopTrackingCoordinator: CoordinatorProtocol {
|
||||
private(set) var didStop = false
|
||||
|
||||
func stop() {
|
||||
didStop = true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -203,6 +203,28 @@ struct NavigationStackCoordinatorTests {
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Stopping
|
||||
|
||||
@Test
|
||||
func stoppingTearsDownTheStackAndEverythingPresentedOverIt() {
|
||||
let rootCoordinator = StopTrackingCoordinator()
|
||||
let pushedCoordinator = StopTrackingCoordinator()
|
||||
let sheetCoordinator = StopTrackingCoordinator()
|
||||
let fullScreenCoverCoordinator = StopTrackingCoordinator()
|
||||
|
||||
navigationStackCoordinator.setRootCoordinator(rootCoordinator)
|
||||
navigationStackCoordinator.push(pushedCoordinator)
|
||||
navigationStackCoordinator.setSheetCoordinator(sheetCoordinator)
|
||||
navigationStackCoordinator.setFullScreenCoverCoordinator(fullScreenCoverCoordinator)
|
||||
|
||||
navigationStackCoordinator.stop()
|
||||
|
||||
#expect(rootCoordinator.didStop)
|
||||
#expect(pushedCoordinator.didStop)
|
||||
#expect(sheetCoordinator.didStop)
|
||||
#expect(fullScreenCoverCoordinator.didStop)
|
||||
}
|
||||
|
||||
// MARK: - Private
|
||||
|
||||
private func assertCoordinatorsEqual(_ lhs: CoordinatorProtocol?, _ rhs: CoordinatorProtocol?) {
|
||||
@@ -219,3 +241,11 @@ struct NavigationStackCoordinatorTests {
|
||||
private class SomeTestCoordinator: CoordinatorProtocol {
|
||||
let id = UUID()
|
||||
}
|
||||
|
||||
private class StopTrackingCoordinator: CoordinatorProtocol {
|
||||
private(set) var didStop = false
|
||||
|
||||
func stop() {
|
||||
didStop = true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -181,6 +181,28 @@ struct NavigationTabCoordinatorTests {
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Stopping
|
||||
|
||||
@Test
|
||||
mutating func stoppingTearsDownTheTabsAndEverythingPresentedOverThem() {
|
||||
let tabCoordinator = StopTrackingCoordinator()
|
||||
let sheetCoordinator = StopTrackingCoordinator()
|
||||
let fullScreenCoverCoordinator = StopTrackingCoordinator()
|
||||
let overlayCoordinator = StopTrackingCoordinator()
|
||||
|
||||
navigationTabCoordinator.setTabs([.init(coordinator: tabCoordinator, details: .init(tag: .tab, title: "Tab", icon: \.help, selectedIcon: \.helpSolid))])
|
||||
navigationTabCoordinator.setSheetCoordinator(sheetCoordinator)
|
||||
navigationTabCoordinator.setFullScreenCoverCoordinator(fullScreenCoverCoordinator)
|
||||
navigationTabCoordinator.setOverlayCoordinator(overlayCoordinator)
|
||||
|
||||
navigationTabCoordinator.stop()
|
||||
|
||||
#expect(tabCoordinator.didStop)
|
||||
#expect(sheetCoordinator.didStop)
|
||||
#expect(fullScreenCoverCoordinator.didStop)
|
||||
#expect(overlayCoordinator.didStop)
|
||||
}
|
||||
|
||||
// MARK: - Private
|
||||
|
||||
private func assertCoordinatorsEqual(_ lhs: CoordinatorProtocol?, _ rhs: CoordinatorProtocol?) {
|
||||
@@ -208,3 +230,11 @@ struct NavigationTabCoordinatorTests {
|
||||
private class SomeTestCoordinator: CoordinatorProtocol {
|
||||
let id = UUID()
|
||||
}
|
||||
|
||||
private class StopTrackingCoordinator: CoordinatorProtocol {
|
||||
private(set) var didStop = false
|
||||
|
||||
func stop() {
|
||||
didStop = true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
import Combine
|
||||
@testable import ElementX
|
||||
import Foundation
|
||||
import SwiftUI
|
||||
import Testing
|
||||
|
||||
@MainActor
|
||||
@@ -20,6 +20,7 @@ struct UserSessionFlowCoordinatorTests {
|
||||
|
||||
private let networkReachabilitySubject: CurrentValueSubject<NetworkMonitorReachability, Never> = .init(.reachable)
|
||||
private let homeserverReachabilitySubject: CurrentValueSubject<HomeserverReachability, Never> = .init(.reachable)
|
||||
private let elementCallService = ElementCallServiceMock(.init())
|
||||
private var tabCoordinator: NavigationTabCoordinator<UserSessionFlowCoordinator.HomeTab>? {
|
||||
rootCoordinator?.rootCoordinator as? NavigationTabCoordinator
|
||||
}
|
||||
@@ -39,13 +40,14 @@ struct UserSessionFlowCoordinatorTests {
|
||||
init() async throws {
|
||||
rootCoordinator = NavigationRootCoordinator()
|
||||
|
||||
let clientProxy = ClientProxyMock(.init(userID: "hi@bob", roomSummaryProvider: RoomSummaryProviderMock(.init(state: .loaded(.mockRooms)))))
|
||||
let clientProxy = ClientProxyMock(.init(userID: "hi@bob", deviceID: "call-device-id", roomSummaryProvider: RoomSummaryProviderMock(.init(state: .loaded(.mockRooms)))))
|
||||
clientProxy.homeserverReachabilityPublisher = homeserverReachabilitySubject.asCurrentValuePublisher()
|
||||
|
||||
let networkMonitor = NetworkMonitorMock(.init())
|
||||
networkMonitor.reachabilityPublisher = networkReachabilitySubject.asCurrentValuePublisher()
|
||||
let appMediator = AppMediatorMock(.init())
|
||||
appMediator.networkMonitor = networkMonitor
|
||||
(appMediator.windowManager as? WindowManagerMock)?.mainWindow = UIWindow()
|
||||
|
||||
userIndicatorController = UserIndicatorControllerMock()
|
||||
let userSession = UserSessionMock(.init(clientProxy: clientProxy))
|
||||
@@ -53,7 +55,7 @@ struct UserSessionFlowCoordinatorTests {
|
||||
let flowParameters = CommonFlowParameters(userSession: userSession,
|
||||
availableSessionsPublisher: .init([.init(userSession: userSession)]),
|
||||
bugReportService: BugReportServiceMock(.init()),
|
||||
elementCallService: ElementCallServiceMock(.init()),
|
||||
elementCallService: elementCallService,
|
||||
timelineControllerFactory: TimelineControllerFactoryMock(.init()),
|
||||
emojiProvider: EmojiProvider(userSettings: userSession.userSettings),
|
||||
linkMetadataProvider: LinkMetadataProvider(),
|
||||
@@ -84,6 +86,20 @@ struct UserSessionFlowCoordinatorTests {
|
||||
#expect((tabCoordinator?.sheetCoordinator as? NavigationStackCoordinator)?.rootCoordinator is SettingsScreenCoordinator)
|
||||
}
|
||||
|
||||
@Test
|
||||
func replacingTheSessionScreensEndsTheWebViewCall() async {
|
||||
// E.g. clearing the cache or signing out during a call: the call screen goes with the screens.
|
||||
await waitForConfirmation { confirmation in
|
||||
elementCallService.setupCallSessionRoomIDRoomDisplayNameIsVideoClosure = { _, _, _ in confirmation() }
|
||||
userSessionFlowCoordinator.handleAppRoute(.call(roomID: "1", isVoiceCall: false), animated: false)
|
||||
}
|
||||
|
||||
rootCoordinator.setRootCoordinator(nil)
|
||||
|
||||
#expect(elementCallService.tearDownCallSessionRoomIDReceivedRoomID == "1",
|
||||
"A call left ongoing would make every later call count as busy")
|
||||
}
|
||||
|
||||
@Test
|
||||
mutating func roomPresentation() async throws {
|
||||
try await process(route: .room(roomID: "1", via: []), expectedChatsState: .roomList(detailState: .room(roomID: "1")))
|
||||
|
||||
Reference in New Issue
Block a user