diff --git a/OmniKitUI/ViewModels/InsertCannulaViewModel.swift b/OmniKitUI/ViewModels/InsertCannulaViewModel.swift index ff80f13..a550caa 100644 --- a/OmniKitUI/ViewModels/InsertCannulaViewModel.swift +++ b/OmniKitUI/ViewModels/InsertCannulaViewModel.swift @@ -130,6 +130,7 @@ class InsertCannulaViewModel: ObservableObject, Identifiable { } @Published var state: InsertCannulaViewModelState = .ready + public var stateNeedsDeliberateUserAcceptance : Bool { switch state { case .ready: @@ -187,7 +188,10 @@ class InsertCannulaViewModel: ObservableObject, Identifiable { self.state = .finished } case .failure(let error): - if self.autoRetryAttempted { + if case .podAlreadyPaired = error { + print("### insertCannula treating podAlreadyPaired as success") + self.state = .finished + } else if self.autoRetryAttempted { self.autoRetryAttempted = false // allow for an auto retry on the next user attempt self.state = .error(error) } else { diff --git a/OmniKitUI/Views/InsertCannulaView.swift b/OmniKitUI/Views/InsertCannulaView.swift index bf8aec8..c5c593b 100644 --- a/OmniKitUI/Views/InsertCannulaView.swift +++ b/OmniKitUI/Views/InsertCannulaView.swift @@ -69,12 +69,14 @@ struct InsertCannulaView: View { if (self.viewModel.error == nil || self.viewModel.error?.recoverable == true) { actionButton .disabled(self.viewModel.state.isProcessing) + .animation(nil) .zIndex(1) } } .transition(AnyTransition.opacity.combined(with: .move(edge: .bottom))) .padding() } + .animation(.default) .alert(isPresented: $cancelModalIsPresented) { cancelPairingModal } .navigationBarTitle(LocalizedString("Insert Cannula", comment: "navigation bar title for insert cannula"), displayMode: .automatic) .navigationBarBackButtonHidden(true) @@ -107,8 +109,6 @@ struct InsertCannulaView: View { } } - - } @@ -131,9 +131,23 @@ struct InsertCannulaView: View { } class MockCannulaInserter: CannulaInserter { + let mockError: Bool = false + let mockPodAlreadyPairedError: Bool = false + func insertCannula(completion: @escaping (Result) -> Void) { - let mockDelay = TimeInterval(seconds: 3) - let result :Result = .success(mockDelay) + let result :Result + if mockError { + if mockPodAlreadyPairedError { + // A podAlreadyPaired "error" should be treated as an immediate success + result = .failure(OmnipodPumpManagerError.podAlreadyPaired) + } else { + // Others should display the error text and show Deactivate Pod & Retry options + result = .failure(OmnipodPumpManagerError.noPodPaired) + } + } else { + let mockDelay = TimeInterval(seconds: 3) + result = .success(mockDelay) + } completion(result) }