diff --git a/CTRTests/Interface/Holder/FuzzyMatching/Send/SendIdentitySelectionViewModelTests.swift b/CTRTests/Interface/Holder/FuzzyMatching/Send/SendIdentitySelectionViewModelTests.swift index 14c9c4baf..bc9ccc492 100644 --- a/CTRTests/Interface/Holder/FuzzyMatching/Send/SendIdentitySelectionViewModelTests.swift +++ b/CTRTests/Interface/Holder/FuzzyMatching/Send/SendIdentitySelectionViewModelTests.swift @@ -50,10 +50,10 @@ final class SendIdentitySelectionViewModelTests: XCTestCase { expect(self.coordinatorDelegateSpy.invokedPresentErrorParameters?.content.body).toEventually(equal( L.holderErrorstateClientMessage("i 1310 000 101"))) } - func test_viewDidAppear_lessThanTwoMatchingBlobs() { + func test_viewDidAppear_emptyMatchingBlobs() { // Given - setupSut(matchingBlobIds: [["123"]], selectedBlobIds: ["123"]) + setupSut(matchingBlobIds: [], selectedBlobIds: ["123"]) // When sut.viewDidAppear() diff --git a/Sources/CTR/Interface/Holder/FuzzyMatching/FuzzyMatchingCoordinator.swift b/Sources/CTR/Interface/Holder/FuzzyMatching/FuzzyMatchingCoordinator.swift index e83065acc..1bbacbc53 100644 --- a/Sources/CTR/Interface/Holder/FuzzyMatching/FuzzyMatchingCoordinator.swift +++ b/Sources/CTR/Interface/Holder/FuzzyMatching/FuzzyMatchingCoordinator.swift @@ -122,15 +122,20 @@ extension FuzzyMatchingCoordinator: FuzzyMatchingCoordinatorDelegate { func userWishesToSeeIdentitiyGroups() { - let viewModel = ListIdentitySelectionViewModel( - coordinatorDelegate: self, - dataSource: dataSource, - matchingBlobIds: matchingBlobIds, - shouldHideSkipButton: shouldHideSkipButton - ) - let viewController = ListIdentitySelectionViewController(viewModel: viewModel) - - navigationController.pushViewController(viewController, animated: true) + if let existingListVC = navigationController.viewControllers.first(where: { $0 is ListIdentitySelectionViewController }) { + navigationController.popToViewController(existingListVC, animated: true) + } else { + + let viewModel = ListIdentitySelectionViewModel( + coordinatorDelegate: self, + dataSource: dataSource, + matchingBlobIds: matchingBlobIds, + shouldHideSkipButton: shouldHideSkipButton + ) + let viewController = ListIdentitySelectionViewController(viewModel: viewModel) + + navigationController.pushViewController(viewController, animated: true) + } } func userHasSelectedIdentityGroup(selectedBlobIds: [String]) { diff --git a/Sources/CTR/Interface/Holder/FuzzyMatching/Send/SendIdentitySelectionViewModel.swift b/Sources/CTR/Interface/Holder/FuzzyMatching/Send/SendIdentitySelectionViewModel.swift index 713f49cb3..50c361899 100644 --- a/Sources/CTR/Interface/Holder/FuzzyMatching/Send/SendIdentitySelectionViewModel.swift +++ b/Sources/CTR/Interface/Holder/FuzzyMatching/Send/SendIdentitySelectionViewModel.swift @@ -44,7 +44,7 @@ class SendIdentitySelectionViewModel { func viewDidAppear() { - guard matchingBlobIds.count > 1, selectedBlobIds.isNotEmpty else { + guard matchingBlobIds.isNotEmpty, selectedBlobIds.isNotEmpty else { displayErrorCode(ErrorCode(flow: .fuzzyMatching, step: .removeEventGroups, clientCode: .noSelectionMade)) return } @@ -107,12 +107,12 @@ class SendIdentitySelectionViewModel { Current.greenCardLoader.signTheEventsIntoGreenCardsAndCredentials(eventMode: nil) { [weak self] result in // Result - + guard let self else { return } switch result { case .success: self.coordinatorDelegate?.userWishesToSeeSuccess(name: self.selectedIdentity ?? "") - + case let .failure(greenCardError): let parser = GreenCardResponseErrorParser(flow: ErrorCode.Flow.fuzzyMatching) switch parser.parse(greenCardError) { @@ -144,8 +144,7 @@ class SendIdentitySelectionViewModel { cancelAction: AlertContent.Action( title: L.generalClose(), action: { [weak self] _ in - guard let self else { return } - self.coordinatorDelegate?.userHasStoppedTheFlow() + self?.coordinatorDelegate?.userWishesToSeeIdentitiyGroups() } ) )