Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tweak the flow for setting up a recovery key. #3463

Merged
merged 7 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@
"banner_migrate_to_native_sliding_sync_description" = "Your server now supports a new, faster protocol. Log out and log back in to upgrade now. Doing this now will help you avoid a forced logout when the old protocol is removed later.";
"banner_migrate_to_native_sliding_sync_force_logout_title" = "Your homeserver no longer supports the old protocol. Please log out and log back in to continue using the app.";
"banner_migrate_to_native_sliding_sync_title" = "Upgrade available";
"banner_set_up_recovery_content" = "Recover your cryptographic identity and message history with a recovery key if you have lost all your existing devices.";
"banner_set_up_recovery_submit" = "Set up recovery";
"banner.set_up_recovery.content" = "Recover your cryptographic identity and message history with a recovery key if you have lost all your existing devices.";
"banner.set_up_recovery.title" = "Set up recovery to protect your account";
"banner_set_up_recovery_title" = "Set up recovery to protect your account";
"common_about" = "About";
"common_acceptable_use_policy" = "Acceptable use policy";
"common_advanced_settings" = "Advanced settings";
Expand Down Expand Up @@ -459,6 +459,7 @@
"screen_chat_backup_key_backup_action_enable" = "Turn on backup";
"screen_chat_backup_key_backup_description" = "Store your cryptographic identity and message keys securely on the server. This will allow you to view your message history on any new devices. %1$@.";
"screen_chat_backup_key_backup_title" = "Key storage";
"screen_chat_backup_key_storage_disabled_error" = "Key storage must be turned on to set up recovery.";
"screen_chat_backup_key_storage_toggle_description" = "Upload keys from this device";
"screen_chat_backup_key_storage_toggle_title" = "Allow key storage";
"screen_chat_backup_recovery_action_change" = "Change recovery key";
Expand Down
15 changes: 6 additions & 9 deletions ElementX/Sources/Generated/Strings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,12 @@ internal enum L10n {
internal static var bannerMigrateToNativeSlidingSyncForceLogoutTitle: String { return L10n.tr("Localizable", "banner_migrate_to_native_sliding_sync_force_logout_title") }
/// Upgrade available
internal static var bannerMigrateToNativeSlidingSyncTitle: String { return L10n.tr("Localizable", "banner_migrate_to_native_sliding_sync_title") }
/// Recover your cryptographic identity and message history with a recovery key if you have lost all your existing devices.
internal static var bannerSetUpRecoveryContent: String { return L10n.tr("Localizable", "banner_set_up_recovery_content") }
/// Set up recovery
internal static var bannerSetUpRecoverySubmit: String { return L10n.tr("Localizable", "banner_set_up_recovery_submit") }
/// Set up recovery to protect your account
internal static var bannerSetUpRecoveryTitle: String { return L10n.tr("Localizable", "banner_set_up_recovery_title") }
/// About
internal static var commonAbout: String { return L10n.tr("Localizable", "common_about") }
/// Acceptable use policy
Expand Down Expand Up @@ -1021,6 +1025,8 @@ internal enum L10n {
}
/// Key storage
internal static var screenChatBackupKeyBackupTitle: String { return L10n.tr("Localizable", "screen_chat_backup_key_backup_title") }
/// Key storage must be turned on to set up recovery.
internal static var screenChatBackupKeyStorageDisabledError: String { return L10n.tr("Localizable", "screen_chat_backup_key_storage_disabled_error") }
/// Upload keys from this device
internal static var screenChatBackupKeyStorageToggleDescription: String { return L10n.tr("Localizable", "screen_chat_backup_key_storage_toggle_description") }
/// Allow key storage
Expand Down Expand Up @@ -2499,15 +2505,6 @@ internal enum L10n {
/// Check UnifiedPush
internal static var troubleshootNotificationsTestUnifiedPushTitle: String { return L10n.tr("Localizable", "troubleshoot_notifications_test_unified_push_title") }

internal enum Banner {
internal enum SetUpRecovery {
/// Recover your cryptographic identity and message history with a recovery key if you have lost all your existing devices.
internal static var content: String { return L10n.tr("Localizable", "banner.set_up_recovery.content") }
/// Set up recovery to protect your account
internal static var title: String { return L10n.tr("Localizable", "banner.set_up_recovery.title") }
}
}

internal enum Common {
/// Copied to clipboard
internal static var copiedToClipboard: String { return L10n.tr("Localizable", "common.copied_to_clipboard") }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class HomeScreenViewModel: HomeScreenViewModelType, HomeScreenViewModelProtocol
switch (securityState.verificationState, securityState.recoveryState) {
case (.verified, .disabled):
state.requiresExtraAccountSetup = true
state.securityBannerMode = .none
state.securityBannerMode = .show
case (.verified, .incomplete):
state.requiresExtraAccountSetup = true

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ struct HomeScreenContent: View {
if context.viewState.slidingSyncMigrationBannerMode == .show {
HomeScreenSlidingSyncMigrationBanner(context: context)
} else if context.viewState.securityBannerMode == .show {
HomeScreenRecoveryKeyConfirmationBanner(context: context)
HomeScreenRecoveryKeyConfirmationBanner(requiresExtraAccountSetup: context.viewState.requiresExtraAccountSetup, context: context)
}
}
.background(Color.compound.bgCanvasDefault)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,18 @@ import Combine
import SwiftUI

struct HomeScreenRecoveryKeyConfirmationBanner: View {
let requiresExtraAccountSetup: Bool
var context: HomeScreenViewModel.Context

var title: String { requiresExtraAccountSetup ? L10n.bannerSetUpRecoveryTitle : L10n.confirmRecoveryKeyBannerTitle }
var message: String { requiresExtraAccountSetup ? L10n.bannerSetUpRecoveryContent : L10n.confirmRecoveryKeyBannerMessage }
var actionTitle: String { requiresExtraAccountSetup ? L10n.bannerSetUpRecoverySubmit : L10n.actionContinue }

var body: some View {
VStack(alignment: .leading, spacing: 16) {
VStack(alignment: .leading, spacing: 4) {
HStack(spacing: 16) {
Text(L10n.confirmRecoveryKeyBannerTitle)
Text(title)
.font(.compound.bodyLGSemibold)
.foregroundColor(.compound.textPrimary)

Expand All @@ -29,12 +34,12 @@ struct HomeScreenRecoveryKeyConfirmationBanner: View {
.frame(width: 12, height: 12)
}
}
Text(L10n.confirmRecoveryKeyBannerMessage)
Text(message)
.font(.compound.bodyMD)
.foregroundColor(.compound.textSecondary)
}

Button(L10n.actionContinue) {
Button(actionTitle) {
context.send(viewAction: .confirmRecoveryKey)
}
.frame(maxWidth: .infinity)
Expand All @@ -52,7 +57,12 @@ struct HomeScreenRecoveryKeyConfirmationBanner_Previews: PreviewProvider, Testab
static let viewModel = buildViewModel()

static var previews: some View {
HomeScreenRecoveryKeyConfirmationBanner(context: viewModel.context)
HomeScreenRecoveryKeyConfirmationBanner(requiresExtraAccountSetup: true,
context: viewModel.context)
.previewDisplayName("Set up recovery")
HomeScreenRecoveryKeyConfirmationBanner(requiresExtraAccountSetup: false,
context: viewModel.context)
.previewDisplayName("Out of sync")
}

static func buildViewModel() -> HomeScreenViewModel {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,6 @@ class SecureBackupRecoveryKeyScreenViewModel: SecureBackupRecoveryKeyScreenViewM
super.init(initialViewState: .init(isModallyPresented: isModallyPresented,
mode: secureBackupController.recoveryState.value.viewMode,
bindings: .init()))

secureBackupController.recoveryState
.receive(on: DispatchQueue.main)
.sink(receiveValue: { [weak self] state in
switch state {
case .settingUp:
self?.showLoadingIndicator()
default:
self?.hideLoadingIndicator()
}
})
.store(in: &cancellables)
}

// MARK: - Public
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ struct SecureBackupScreen: View {
}
}
.compoundList()
.navigationTitle(L10n.commonChatBackup)
.navigationTitle(L10n.commonEncryption)
.navigationBarTitleDisplayMode(.inline)
.alert(item: $context.alertInfo)
}
Expand Down Expand Up @@ -68,8 +68,7 @@ struct SecureBackupScreen: View {
}

private var keyStorageToggle: some View {
ListRow(label: .plain(title: L10n.screenChatBackupKeyStorageToggleTitle,
description: L10n.screenChatBackupKeyStorageToggleDescription),
ListRow(label: .plain(title: L10n.screenChatBackupKeyStorageToggleTitle),
kind: .toggle($context.keyStorageEnabled))
.onChange(of: context.keyStorageEnabled) { _, newValue in
context.send(viewAction: .keyStorageToggled(newValue))
Expand All @@ -86,7 +85,10 @@ struct SecureBackupScreen: View {
iconAlignment: .top),
kind: .navigationLink { context.send(viewAction: .recoveryKey) })
case .disabled:
ListRow(label: .plain(title: L10n.screenChatBackupRecoveryActionSetup),
ListRow(label: .default(title: L10n.screenChatBackupRecoveryActionSetup,
description: L10n.screenChatBackupRecoveryActionChangeDescription,
icon: \.key,
iconAlignment: .top),
details: .icon(BadgeView(size: 10)),
kind: .navigationLink { context.send(viewAction: .recoveryKey) })
case .incomplete:
Expand All @@ -105,8 +107,6 @@ struct SecureBackupScreen: View {
@ViewBuilder
private var recoveryKeySectionFooter: some View {
switch context.viewState.recoveryState {
case .disabled:
Text(L10n.screenChatBackupRecoveryActionSetupDescription(InfoPlistReader.main.bundleDisplayName))
case .incomplete:
Text(L10n.screenChatBackupRecoveryActionConfirmDescription)
default:
Expand Down

This file was deleted.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

This file was deleted.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions UnitTests/Sources/MediaUploadingPreprocessorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ final class MediaUploadingPreprocessorTests: XCTestCase {
}

func testLandscapeMovVideoProcessing() async {
// Allow double the default execution time as we encode the video twice now.
executionTimeAllowance = 120
// Allow an increased execution time as we encode the video twice now.
executionTimeAllowance = 180

guard let url = Bundle(for: Self.self).url(forResource: "landscape_test_video.mov", withExtension: nil) else {
XCTFail("Failed retrieving test asset")
Expand Down Expand Up @@ -109,8 +109,8 @@ final class MediaUploadingPreprocessorTests: XCTestCase {
}

func testPortraitMp4VideoProcessing() async {
// Allow double the default execution time as we encode the video twice now.
executionTimeAllowance = 120
// Allow an increased execution time as we encode the video twice now.
executionTimeAllowance = 180

guard let url = Bundle(for: Self.self).url(forResource: "portrait_test_video.mp4", withExtension: nil) else {
XCTFail("Failed retrieving test asset")
Expand Down
Loading