Move the account migration screen to within the room list

This commit is contained in:
Stefan Ceriu
2024-01-26 11:39:26 +02:00
committed by Stefan Ceriu
parent 33a81989b0
commit f0d971c1ab
22 changed files with 349 additions and 519 deletions
@@ -42,7 +42,6 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
private var bugReportFlowCoordinator: BugReportFlowCoordinator?
private var cancellables = Set<AnyCancellable>()
private var migrationCancellable: AnyCancellable?
private let sidebarNavigationStackCoordinator: NavigationStackCoordinator
private let detailNavigationStackCoordinator: NavigationStackCoordinator
@@ -137,10 +136,7 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
}
func start() {
if appSettings.migratedAccounts[userSession.userID] != true {
// Show the migration screen for a new account.
stateMachine.processEvent(.startWithMigration)
} else if !appSettings.hasShownWelcomeScreen {
if !appSettings.hasShownWelcomeScreen {
stateMachine.processEvent(.startWithWelcomeScreen)
} else {
// Otherwise go straight to the home screen.
@@ -220,12 +216,6 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
case (.initial, .start, .roomList):
presentHomeScreen()
case (.initial, .startWithMigration, .migration):
presentMigrationScreen() // Full screen cover
presentHomeScreen() // Have the home screen ready to show underneath
case (.migration, .completeMigration, .roomList):
dismissMigrationScreen()
case (.initial, .startWithWelcomeScreen, .welcomeScreen):
presentHomeScreen()
presentWelcomeScreen()
@@ -304,33 +294,6 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
}
}
private func presentMigrationScreen() {
// Listen for the first sync to finish.
migrationCancellable = userSession.clientProxy.callbacks
.receive(on: DispatchQueue.main)
.sink { [weak self] callback in
guard let self, stateMachine.state == .migration, case .receivedSyncUpdate = callback else { return }
migrationCancellable = nil
appSettings.migratedAccounts[userSession.userID] = true
stateMachine.processEvent(.completeMigration)
}
let coordinator = MigrationScreenCoordinator()
navigationSplitCoordinator.setFullScreenCoverCoordinator(coordinator)
}
private func dismissMigrationScreen() {
navigationSplitCoordinator.setFullScreenCoverCoordinator(nil)
// Not sure why but the full screen closure dismissal closure doesn't seem to work properly
// And not using the DispatchQueue.main results in the the screen getting presented as full screen too.
if !appSettings.hasShownWelcomeScreen {
DispatchQueue.main.async {
self.stateMachine.processEvent(.presentWelcomeScreen)
}
}
}
private func presentHomeScreen() {
let parameters = HomeScreenCoordinatorParameters(userSession: userSession,
attributedStringBuilder: AttributedStringBuilder(permalinkBaseURL: ServiceLocator.shared.settings.permalinkBaseURL,
@@ -23,9 +23,6 @@ class UserSessionFlowCoordinatorStateMachine {
/// The initial state, used before the coordinator starts
case initial
/// Showing the migration screen whilst the proxy performs an initial sync.
case migration
/// Showing the welcome screen.
case welcomeScreen
@@ -63,11 +60,6 @@ class UserSessionFlowCoordinatorStateMachine {
/// **Note:** This is event is only for users who used the app before v1.1.8.
/// It can be removed once the older TestFlight builds have expired.
case startWithWelcomeScreen
/// Start the user session flows with a migration screen.
case startWithMigration
/// Request to transition from the migration state to the home screen.
case completeMigration
/// Request presentation of the welcome screen.
case presentWelcomeScreen
@@ -124,9 +116,7 @@ class UserSessionFlowCoordinatorStateMachine {
private func configure() {
stateMachine.addRoutes(event: .start, transitions: [.initial => .roomList(selectedRoomID: nil)])
stateMachine.addRoutes(event: .startWithMigration, transitions: [.initial => .migration])
stateMachine.addRoutes(event: .startWithWelcomeScreen, transitions: [.initial => .welcomeScreen])
stateMachine.addRoutes(event: .completeMigration, transitions: [.migration => .roomList(selectedRoomID: nil)])
stateMachine.addRoutes(event: .dismissedWelcomeScreen, transitions: [.welcomeScreen => .roomList(selectedRoomID: nil)])
stateMachine.addRouteMapping { event, fromState, _ in