diff --git a/vector/src/main/java/im/vector/app/features/crypto/quads/SharedSecureStorageViewModel.kt b/vector/src/main/java/im/vector/app/features/crypto/quads/SharedSecureStorageViewModel.kt index 951ff4ede6..862b2de85a 100644 --- a/vector/src/main/java/im/vector/app/features/crypto/quads/SharedSecureStorageViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/crypto/quads/SharedSecureStorageViewModel.kt @@ -140,6 +140,12 @@ class SharedSecureStorageViewModel @AssistedInject constructor( } private fun handleDoResetAll() { + // as we are going to reset, we'd better cancel all outgoing requests + // if not they could be accepted in the middle of the reset process + // and cause strange use cases + session.cryptoService().verificationService().getExistingVerificationRequest(session.myUserId)?.forEach { + session.cryptoService().verificationService().cancelVerificationRequest(it) + } _viewEvents.post(SharedSecureStorageViewEvent.ShowResetBottomSheet) } diff --git a/vector/src/main/java/im/vector/app/features/crypto/recover/BootstrapCrossSigningTask.kt b/vector/src/main/java/im/vector/app/features/crypto/recover/BootstrapCrossSigningTask.kt index b7c689f41f..47e373ed0a 100644 --- a/vector/src/main/java/im/vector/app/features/crypto/recover/BootstrapCrossSigningTask.kt +++ b/vector/src/main/java/im/vector/app/features/crypto/recover/BootstrapCrossSigningTask.kt @@ -237,7 +237,7 @@ class BootstrapCrossSigningTask @Inject constructor( Timber.d("## BootstrapCrossSigningTask: Creating 4S - Checking megolm backup") // First ensure that in sync - val serverVersion = awaitCallback { + var serverVersion = awaitCallback { session.cryptoService().keysBackupService().getCurrentVersion(it) } @@ -247,6 +247,16 @@ class BootstrapCrossSigningTask @Inject constructor( || (params.setupMode == SetupMode.PASSPHRASE_AND_NEEDED_SECRETS_RESET && !isMegolmBackupSecretKnown) || (params.setupMode == SetupMode.HARD_RESET) if (shouldCreateKeyBackup) { + // clear all existing backups + while (serverVersion != null) { + awaitCallback { + session.cryptoService().keysBackupService().deleteBackup(serverVersion!!.version, it) + } + serverVersion = awaitCallback { + session.cryptoService().keysBackupService().getCurrentVersion(it) + } + } + Timber.d("## BootstrapCrossSigningTask: Creating 4S - Create megolm backup") val creationInfo = awaitCallback { session.cryptoService().keysBackupService().prepareKeysBackupVersion(null, null, it) diff --git a/vector/src/main/java/im/vector/app/features/crypto/verification/IncomingVerificationRequestHandler.kt b/vector/src/main/java/im/vector/app/features/crypto/verification/IncomingVerificationRequestHandler.kt index e42eb6de6f..7d98b7c2a5 100644 --- a/vector/src/main/java/im/vector/app/features/crypto/verification/IncomingVerificationRequestHandler.kt +++ b/vector/src/main/java/im/vector/app/features/crypto/verification/IncomingVerificationRequestHandler.kt @@ -164,7 +164,7 @@ class IncomingVerificationRequestHandler @Inject constructor( override fun verificationRequestUpdated(pr: PendingVerificationRequest) { // If an incoming request is readied (by another device?) we should discard the alert - if (pr.isIncoming && (pr.isReady || pr.handledByOtherSession)) { + if (pr.isIncoming && (pr.isReady || pr.handledByOtherSession || pr.cancelConclusion != null)) { popupAlertManager.cancelAlert(uniqueIdForVerificationRequest(pr)) } }