Skip to content
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
3 changes: 2 additions & 1 deletion Loop/Managers/Alerts/AlertManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ public final class AlertManager {
.sink { [weak self] publisher in
if let loopDataManager = publisher.object as? LoopDataManager {
Task { @MainActor in
await self?.loopDidComplete(loopDataManager.lastLoopCompleted)
let manualTempBasalRunning = loopDataManager.deliveryDelegate?.isManualTempBasalRunning == true
await self?.loopDidComplete(manualTempBasalRunning ? nil : loopDataManager.lastLoopCompleted)
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions Loop/Managers/DeviceDataManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1449,6 +1449,10 @@ extension DeviceDataManager: PumpManagerDeliveryDelegate {
try await doseEnactor.enact(decisionId: decisionId, bolus: bolus, tempBasal: tempBasal, with: pumpManager)
}

var isAutomaticDosingActive: Bool {
settingsManager.dosingEnabled && !isManualTempBasalRunning
}

var isPumpInoperable: Bool {
guard let basalDeliveryState else {
return true
Expand Down
2 changes: 1 addition & 1 deletion Loop/Managers/ExtensionDataManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ final class ExtensionDataManager {
context.mostRecentGlucoseDataDate = loopDataManager.mostRecentGlucoseDataDate
context.mostRecentPumpDataDate = loopDataManager.mostRecentPumpDataDate

context.isClosedLoop = self.settingsManager.dosingEnabled
context.isClosedLoop = self.deviceManager.isAutomaticDosingActive

context.preMealPresetAllowed = self.settingsManager.dosingEnabled && self.settingsManager.settings.preMealTargetRange != nil
context.preMealPresetActive = self.temporaryPresetsManager.isPreMealTargetActive()
Expand Down
2 changes: 1 addition & 1 deletion Loop/Managers/WatchDataManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ final class WatchDataManager: NSObject {

let settings = self.settingsManager.loopSettings

context.isClosedLoop = settings.dosingEnabled
context.isClosedLoop = deviceManager.isAutomaticDosingActive
context.isOnboardingCompleted = deviceManager.cgmManager?.isOnboarded == true && deviceManager.pumpManager?.isOnboarded == true
context.deviceIssue = deviceManager.cgmManager == nil || deviceManager.cgmManager?.isInoperable == true || deviceManager.cgmManager?.inSignalLoss == true || deviceManager.pumpManager == nil || deviceManager.pumpManager?.isInoperable == true || deviceManager.pumpManager?.inSignalLoss == true || deviceManager.hasBluetoothIssue

Expand Down
5 changes: 3 additions & 2 deletions Loop/View Controllers/StatusTableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,7 @@ final class StatusTableViewController: LoopChartsTableViewController {
if oldValue != basalDeliveryState {
Task { @MainActor in
log.debug("New basalDeliveryState: %@", String(describing: basalDeliveryState))
hudView?.loopCompletionHUD.loopIconClosed = deviceManager.isAutomaticDosingActive
refreshContext.update(with: .status)
await reloadData(animated: true)
}
Expand Down Expand Up @@ -1731,7 +1732,7 @@ final class StatusTableViewController: LoopChartsTableViewController {

private func automaticDosingStatusChanged(_ automaticDosingEnabled: Bool) {
log.debug("automaticDosingStatusChanged -> %{public}@", String(describing: automaticDosingEnabled))
hudView?.loopCompletionHUD.loopIconClosed = automaticDosingEnabled
hudView?.loopCompletionHUD.loopIconClosed = deviceManager.isAutomaticDosingActive
hudView?.loopCompletionHUD.closedLoopDisallowedLocalizedDescription = deviceManager.closedLoopDisallowedLocalizedDescription

if automaticDosingEnabled {
Expand Down Expand Up @@ -1765,7 +1766,7 @@ final class StatusTableViewController: LoopChartsTableViewController {

// when HUD view is initialized, update loop completion HUD (e.g., icon and last loop completed)
hudView.loopCompletionHUD.stateColors = .loopStatus
hudView.loopCompletionHUD.loopIconClosed = settingsManager.dosingEnabled
hudView.loopCompletionHUD.loopIconClosed = deviceManager.isAutomaticDosingActive
hudView.loopCompletionHUD.lastLoopCompleted = loopManager.lastLoopCompleted
hudView.loopCompletionHUD.mostRecentGlucoseDataDate = loopManager.mostRecentGlucoseDataDate
hudView.loopCompletionHUD.mostRecentPumpDataDate = loopManager.mostRecentPumpDataDate
Expand Down
4 changes: 3 additions & 1 deletion Loop/Views/LoopStatusModalView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ class LoopStatusModalViewModel {
}

var loopIconClosed: Bool {
settingsManager?.dosingEnabled ?? true
deviceManager?.isAutomaticDosingActive ?? settingsManager?.dosingEnabled ?? true
}

var hasBluetoothIssue: Bool {
Expand Down Expand Up @@ -246,6 +246,8 @@ class LoopStatusModalViewModel {
return (titleDeviceIssue, NSLocalizedString("Tap your CGM or insulin pump status icons right away for more information and steps to resolve the issue.", comment: "message when automation is off and there is a bluetooth or pump issue"))
} else if isDeliverySuspended {
return (titleAutomationOff, NSLocalizedString("Resume insulin if you wish for the app to restart insulin delivery.\n\nIf you wish for the app to automate your insulin, go to Settings and toggle Closed Loop to on.", comment: "message when automation is off and insulin delivery is suspended"))
} else if isManualTempBasalRunning, settingsManager?.dosingEnabled == true {
return (titleAutomationOff, NSLocalizedString("Your pump and CGM will continue to operate, but the app will not adjust insulin dosing while a manual temporary basal is in progress.\n\nCancel the manual temporary basal if you wish for the app to restart automated dosing.", comment: "message when closed loop is on and a manual temp basal is in progress"))
} else if isManualTempBasalRunning {
return (titleAutomationOff, NSLocalizedString("Cancel the manual temporary basal if you wish for the app to restart automated dosing.\n\nIf you wish for the app to automate your insulin, go to Settings and toggle Closed Loop to on.", comment: "message when automation is off and a manual temp basal is in progress"))
} else if isCGMInoperable {
Expand Down