Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for perpetual Insert Cannula "Pod Already Paired" errors #127

Merged
merged 2 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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")
marionbarker marked this conversation as resolved.
Show resolved Hide resolved
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 {
Expand Down
22 changes: 18 additions & 4 deletions OmniBLE/PumpManagerUI/Views/InsertCannulaView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -132,16 +132,30 @@ struct InsertCannulaView: View {
}

class MockCannulaInserter: CannulaInserter {
let mockError: Bool = false
let mockPodAlreadyPairedError: Bool = false

func insertCannula(completion: @escaping (Result<TimeInterval,OmniBLEPumpManagerError>) -> Void) {
let mockDelay = TimeInterval(seconds: 3)
let result :Result<TimeInterval, OmniBLEPumpManagerError> = .success(mockDelay)
let result :Result<TimeInterval, OmniBLEPumpManagerError>
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
}

Expand Down