From 13d2fa70608fef93fcfc78f83d65c0f29c834b84 Mon Sep 17 00:00:00 2001 From: Stefan Ceriu Date: Fri, 9 Aug 2024 13:11:34 +0300 Subject: [PATCH] Manually cancel the identity reset handle when dismissing the EncryptionReset screen. --- .../EncryptionResetScreenCoordinator.swift | 4 ++++ .../EncryptionResetScreenViewModel.swift | 6 ++++++ .../EncryptionResetScreenViewModelProtocol.swift | 1 + 3 files changed, 11 insertions(+) diff --git a/ElementX/Sources/Screens/EncryptionReset/EncryptionResetScreen/EncryptionResetScreenCoordinator.swift b/ElementX/Sources/Screens/EncryptionReset/EncryptionResetScreen/EncryptionResetScreenCoordinator.swift index 56bb0392b0..f95ebbe7d0 100644 --- a/ElementX/Sources/Screens/EncryptionReset/EncryptionResetScreen/EncryptionResetScreenCoordinator.swift +++ b/ElementX/Sources/Screens/EncryptionReset/EncryptionResetScreen/EncryptionResetScreenCoordinator.swift @@ -64,6 +64,10 @@ final class EncryptionResetScreenCoordinator: CoordinatorProtocol { } .store(in: &cancellables) } + + func stop() { + viewModel.stop() + } func toPresentable() -> AnyView { AnyView(EncryptionResetScreen(context: viewModel.context)) diff --git a/ElementX/Sources/Screens/EncryptionReset/EncryptionResetScreen/EncryptionResetScreenViewModel.swift b/ElementX/Sources/Screens/EncryptionReset/EncryptionResetScreen/EncryptionResetScreenViewModel.swift index 61db33d49a..7582e0fe1b 100644 --- a/ElementX/Sources/Screens/EncryptionReset/EncryptionResetScreen/EncryptionResetScreenViewModel.swift +++ b/ElementX/Sources/Screens/EncryptionReset/EncryptionResetScreen/EncryptionResetScreenViewModel.swift @@ -61,6 +61,12 @@ class EncryptionResetScreenViewModel: EncryptionResetScreenViewModelType, Encryp } } + func stop() { + Task { + await identityResetHandle?.cancel() + } + } + // MARK: - Private private func startResetFlow() async { diff --git a/ElementX/Sources/Screens/EncryptionReset/EncryptionResetScreen/EncryptionResetScreenViewModelProtocol.swift b/ElementX/Sources/Screens/EncryptionReset/EncryptionResetScreen/EncryptionResetScreenViewModelProtocol.swift index fe96ce0e83..8eb9262b7a 100644 --- a/ElementX/Sources/Screens/EncryptionReset/EncryptionResetScreen/EncryptionResetScreenViewModelProtocol.swift +++ b/ElementX/Sources/Screens/EncryptionReset/EncryptionResetScreen/EncryptionResetScreenViewModelProtocol.swift @@ -22,4 +22,5 @@ protocol EncryptionResetScreenViewModelProtocol { var context: EncryptionResetScreenViewModelType.Context { get } func continueResetFlowWith(password: String) + func stop() }