diff --git a/OmniBLE/PumpManagerUI/ViewModels/InsertCannulaViewModel.swift b/OmniBLE/PumpManagerUI/ViewModels/InsertCannulaViewModel.swift index 733fc36b..a26c24a6 100644 --- a/OmniBLE/PumpManagerUI/ViewModels/InsertCannulaViewModel.swift +++ b/OmniBLE/PumpManagerUI/ViewModels/InsertCannulaViewModel.swift @@ -187,7 +187,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/OmniBLE/PumpManagerUI/Views/InsertCannulaView.swift b/OmniBLE/PumpManagerUI/Views/InsertCannulaView.swift index 30133eed..e4a66da9 100644 --- a/OmniBLE/PumpManagerUI/Views/InsertCannulaView.swift +++ b/OmniBLE/PumpManagerUI/Views/InsertCannulaView.swift @@ -132,16 +132,30 @@ 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(OmniBLEPumpManagerError.podAlreadyPaired) + } else { + // Others should display the error text and show Deactivate Pod & Retry options + result = .failure(OmniBLEPumpManagerError.noPodPaired) + } + } else { + let mockDelay = TimeInterval(seconds: 3) + result = .success(mockDelay) + } completion(result) } - + func checkCannulaInsertionFinished(completion: @escaping (OmniBLEPumpManagerError?) -> Void) { completion(nil) } - + var cannulaInsertionSuccessfullyStarted: Bool = false }