Fixes #3146 - Remove the account migration screen

This commit is contained in:
Stefan Ceriu 2024-08-12 11:58:22 +03:00 committed by Stefan Ceriu
parent cce42a7126
commit 6759a66533
13 changed files with 6 additions and 146 deletions

View File

@ -356,20 +356,6 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationFlowCoordinatorDeleg
MXLog.info("The app was upgraded from \(oldVersion) to \(newVersion)")
if oldVersion < Version(1, 1, 0) {
MXLog.info("Migrating to v1.1.0, signing out the user.")
// Version 1.1.0 switched the Rust crypto store to SQLite
// There are no migrations in place so we need to sign the user out
wipeUserData()
}
if oldVersion < Version(1, 1, 7) {
MXLog.info("Migrating to v1.1.7, marking accounts as migrated.")
for userID in userSessionStore.userIDs {
appSettings.migratedAccounts[userID] = true
}
}
if oldVersion < Version(1, 6, 0) {
MXLog.info("Migrating to v1.6.0, marking identity confirmation onboarding as ran.")
if !userSessionStore.userIDs.isEmpty {

View File

@ -14,7 +14,6 @@ final class AppSettings {
case lastVersionLaunched
case appLockNumberOfPINAttempts
case appLockNumberOfBiometricAttempts
case migratedAccounts
case timelineStyle
case analyticsConsentState
@ -159,14 +158,7 @@ final class AppSettings {
contacts: [supportEmailAddress],
staticRegistrations: oidcStaticRegistrations.mapKeys { $0.absoluteString },
dynamicRegistrationsFile: .sessionsBaseDirectory.appending(path: "oidc/registrations.json"))
/// A dictionary of accounts that have performed an initial sync through their proxy.
///
/// This is a temporary workaround. In the future we should be able to receive a signal from the
/// proxy that it is the first sync (or that an upgrade on the backend will involve a slower sync).
@UserPreference(key: UserDefaultsKeys.migratedAccounts, defaultValue: [:], storageType: .userDefaults(store))
var migratedAccounts: [String: Bool]
// MARK: - Notifications
var pusherAppId: String {

View File

@ -32,7 +32,6 @@ enum A11yIdentifiers {
static let roomMemberDetailsScreen = RoomMemberDetailsScreen()
static let createRoomScreen = CreateRoomScreen()
static let inviteUsersScreen = InviteUsersScreen()
static let migrationScreen = MigrationScreen()
static let notificationSettingsScreen = NotificationSettingsScreen()
static let notificationSettingsEditScreen = NotificationSettingsEditScreen()
static let pollFormScreen = PollFormScreen()
@ -239,10 +238,6 @@ enum A11yIdentifiers {
"\(optionPrefix)-\(index)"
}
}
struct MigrationScreen {
let message = "migration_screen-message"
}
struct NotificationSettingsScreen {
let fixMismatchConfiguration = "notification_settings_screen-fix_mismatch_configuration"

View File

@ -43,15 +43,12 @@ enum HomeScreenViewAction {
}
enum HomeScreenRoomListMode: CustomStringConvertible {
case migration
case skeletons
case empty
case rooms
var description: String {
switch self {
case .migration:
return "Showing account migration"
case .skeletons:
return "Showing placeholders"
case .empty:

View File

@ -19,8 +19,6 @@ class HomeScreenViewModel: HomeScreenViewModelType, HomeScreenViewModelProtocol
private let roomSummaryProvider: RoomSummaryProviderProtocol?
private var migrationCancellable: AnyCancellable?
private var actionsSubject: PassthroughSubject<HomeScreenViewModelAction, Never> = .init()
var actions: AnyPublisher<HomeScreenViewModelAction, Never> {
actionsSubject.eraseToAnyPublisher()
@ -223,27 +221,7 @@ class HomeScreenViewModel: HomeScreenViewModelType, HomeScreenViewModelProtocol
}
analyticsService.signpost.beginFirstRooms()
let hasUserBeenMigrated = appSettings.migratedAccounts[userSession.clientProxy.userID] == true
if !hasUserBeenMigrated {
state.roomListMode = .migration
MXLog.info("Account not migrated, setting view room list mode to \"\(state.roomListMode)\"")
migrationCancellable = userSession.clientProxy.actionsPublisher
.receive(on: DispatchQueue.main)
.sink { [weak self] callback in
guard let self, case .receivedSyncUpdate = callback else { return }
migrationCancellable = nil
appSettings.migratedAccounts[userSession.clientProxy.userID] = true
MXLog.info("Received first sync response, updating room list mode")
updateRoomListMode(with: roomSummaryProvider.statePublisher.value)
}
}
roomSummaryProvider.statePublisher
.receive(on: DispatchQueue.main)
.sink { [weak self] state in
@ -262,11 +240,6 @@ class HomeScreenViewModel: HomeScreenViewModelType, HomeScreenViewModelProtocol
}
private func updateRoomListMode(with roomSummaryProviderState: RoomSummaryProviderState) {
guard appSettings.migratedAccounts[userSession.clientProxy.userID] == true else {
// Ignore room summary provider updates while "migrating"
return
}
let isLoadingData = !roomSummaryProviderState.isLoaded
let hasNoRooms = roomSummaryProviderState.isLoaded && roomSummaryProviderState.totalNumberOfRooms == 0

View File

@ -188,17 +188,11 @@ struct HomeScreen: View {
// MARK: - Previews
struct HomeScreen_Previews: PreviewProvider, TestablePreview {
static let migratingViewModel = viewModel(.migration)
static let loadingViewModel = viewModel(.skeletons)
static let emptyViewModel = viewModel(.empty)
static let loadedViewModel = viewModel(.rooms)
static var previews: some View {
NavigationStack {
HomeScreen(context: migratingViewModel.context)
}
.previewDisplayName("Migrating")
NavigationStack {
HomeScreen(context: loadingViewModel.context)
}
@ -218,14 +212,9 @@ struct HomeScreen_Previews: PreviewProvider, TestablePreview {
}
static func viewModel(_ mode: HomeScreenRoomListMode) -> HomeScreenViewModel {
let userID = mode == .migration ? "@unmigrated_alice:example.com" : "@alice:example.com"
let appSettings = AppSettings() // This uses shared storage under the hood
appSettings.migratedAccounts[userID] = mode != .migration
let userID = "@alice:example.com"
let roomSummaryProviderState: RoomSummaryProviderMockConfigurationState = switch mode {
case .migration:
.loading
case .skeletons:
.loading
case .empty:
@ -241,7 +230,7 @@ struct HomeScreen_Previews: PreviewProvider, TestablePreview {
return HomeScreenViewModel(userSession: userSession,
analyticsService: ServiceLocator.shared.analytics,
appSettings: appSettings,
appSettings: ServiceLocator.shared.settings,
selectedRoomPublisher: CurrentValueSubject<String?, Never>(nil).asCurrentValuePublisher(),
userIndicatorController: ServiceLocator.shared.userIndicatorController)
}

View File

@ -16,13 +16,8 @@ struct HomeScreenContent: View {
let scrollViewAdapter: ScrollViewAdapter
var body: some View {
switch context.viewState.roomListMode {
case .migration:
migrationView
default:
roomList
.sentryTrace("\(Self.self)")
}
roomList
.sentryTrace("\(Self.self)")
}
private var roomList: some View {
@ -59,8 +54,6 @@ struct HomeScreenContent: View {
.searchable(text: $context.searchQuery, placement: .navigationBarDrawer(displayMode: .always))
.compoundSearchField()
.disableAutocorrection(true)
case .migration:
EmptyView()
}
}
.introspect(.scrollView, on: .supportedVersions) { scrollView in
@ -141,47 +134,6 @@ struct HomeScreenContent: View {
}
}
@ViewBuilder
private var migrationView: some View {
if UIDevice.current.isPhone {
if verticalSizeClass == .compact {
migrationViewContent
.frame(maxWidth: .infinity, maxHeight: .infinity)
} else {
WaitingDialog {
migrationViewContent
} bottomContent: {
EmptyView()
}
}
} else {
migrationViewContent
.frame(maxWidth: .infinity, maxHeight: .infinity)
}
}
private var migrationViewContent: some View {
VStack(spacing: 16) {
ProgressView()
.tint(.compound.iconPrimary)
.padding(.bottom, 4)
Text(L10n.screenMigrationTitle.tinting(".", color: Asset.Colors.brandColor.swiftUIColor))
.minimumScaleFactor(0.01)
.font(.compound.headingXLBold)
.multilineTextAlignment(.center)
.foregroundColor(.compound.textPrimary)
Text(L10n.screenMigrationMessage)
.minimumScaleFactor(0.01)
.font(.compound.bodyLG)
.multilineTextAlignment(.center)
.foregroundColor(.compound.textPrimary)
.accessibilityIdentifier(A11yIdentifiers.migrationScreen.message)
}
.padding(.horizontal)
}
/// Often times the scroll view's content size isn't correct yet when this method is called e.g. when cancelling a search
/// Dispatch it with a delay to allow the UI to update and the computations to be correct
/// Once we move to iOS 17 we should remove all of this and use scroll anchors instead

View File

@ -522,7 +522,6 @@ class MockScreen: Identifiable {
let navigationSplitCoordinator = NavigationSplitCoordinator(placeholderCoordinator: PlaceholderScreenCoordinator())
let clientProxy = ClientProxyMock(.init(userID: "@mock:client.com", deviceID: "MOCKCLIENT", roomSummaryProvider: RoomSummaryProviderMock(.init(state: .loaded(.mockRooms)))))
ServiceLocator.shared.settings.migratedAccounts[clientProxy.userID] = true
let appMediator = AppMediatorMock.default
appMediator.underlyingWindowManager = windowManager
@ -635,8 +634,6 @@ class MockScreen: Identifiable {
clientProxy.roomForIdentifierReturnValue = .joined(roomProxy)
ServiceLocator.shared.settings.migratedAccounts[clientProxy.userID] = true
let timelineController = RoomTimelineController(roomProxy: roomProxy,
timelineProxy: roomProxy.timeline,
initialFocussedEventID: nil,

View File

@ -65,15 +65,6 @@ extension XCUIApplication {
savePasswordButton.tap()
}
// Migration screen may be shown as an overlay.
// if that pops up soon enough, we just let that happen and wait
let message = staticTexts[A11yIdentifiers.migrationScreen.message]
if message.waitForExistence(timeout: 10.0) {
currentTestCase.expectation(for: doesNotExistPredicate, evaluatedWith: message)
currentTestCase.waitForExpectations(timeout: 300.0)
}
// Wait for the home screen to become visible.
let profileButton = buttons[A11yIdentifiers.homeScreen.userAvatar]