Skip to content

Commit f619cad

Browse files
authored
[COASTAL-102] Set-max-bolus-limit
* support syncing delivery limits * response to PR comments
1 parent f7586e6 commit f619cad

File tree

4 files changed

+18
-3
lines changed

4 files changed

+18
-3
lines changed

Loop/View Controllers/StatusTableViewController.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1394,6 +1394,9 @@ final class StatusTableViewController: LoopChartsTableViewController {
13941394
let syncBasalRateSchedule = { [weak self] in
13951395
self?.deviceManager.pumpManager?.syncBasalRateSchedule
13961396
}
1397+
let syncDeliveryLimits = { [weak self] in
1398+
self?.deviceManager.pumpManager?.syncDeliveryLimits
1399+
}
13971400
let servicesViewModel = ServicesViewModel(showServices: FeatureFlags.includeServicesInSettingsEnabled,
13981401
availableServices: { [weak self] in self?.deviceManager.servicesManager.availableServices ?? [] },
13991402
activeServices: { [weak self] in self?.deviceManager.servicesManager.activeServices ?? [] },
@@ -1406,6 +1409,7 @@ final class StatusTableViewController: LoopChartsTableViewController {
14061409
therapySettings: { [weak self] in self?.deviceManager.loopManager.therapySettings ?? TherapySettings() },
14071410
pumpSupportedIncrements: pumpSupportedIncrements,
14081411
syncPumpSchedule: syncBasalRateSchedule,
1412+
syncDeliveryLimits: syncDeliveryLimits,
14091413
sensitivityOverridesEnabled: FeatureFlags.sensitivityOverridesEnabled,
14101414
initialDosingEnabled: deviceManager.loopManager.settings.dosingEnabled,
14111415
isClosedLoopAllowed: closedLoopStatus.$isClosedLoopAllowed,

Loop/View Models/SettingsViewModel.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,10 @@ public class SettingsViewModel: ObservableObject {
8080
let servicesViewModel: ServicesViewModel
8181
let criticalEventLogExportViewModel: CriticalEventLogExportViewModel
8282
let therapySettings: () -> TherapySettings
83+
// TODO This pattern of taking a closure that returns a closure is redundant; we should simplify here.
8384
let pumpSupportedIncrements: (() -> PumpSupportedIncrements?)?
84-
let syncPumpSchedule: (() -> PumpManager.SyncSchedule?)?
85+
let syncPumpSchedule: (() -> SyncSchedule?)?
86+
let syncDeliveryLimits: (() -> SyncDeliveryLimits?)?
8587
let sensitivityOverridesEnabled: Bool
8688
let supportInfoProvider: SupportInfoProvider
8789
let isOnboardingComplete: Bool
@@ -108,7 +110,8 @@ public class SettingsViewModel: ObservableObject {
108110
criticalEventLogExportViewModel: CriticalEventLogExportViewModel,
109111
therapySettings: @escaping () -> TherapySettings,
110112
pumpSupportedIncrements: (() -> PumpSupportedIncrements?)?,
111-
syncPumpSchedule: (() -> PumpManager.SyncSchedule?)?,
113+
syncPumpSchedule: (() -> SyncSchedule?)?,
114+
syncDeliveryLimits: (() -> SyncDeliveryLimits?)?,
112115
sensitivityOverridesEnabled: Bool,
113116
initialDosingEnabled: Bool,
114117
isClosedLoopAllowed: Published<Bool>.Publisher,
@@ -126,6 +129,7 @@ public class SettingsViewModel: ObservableObject {
126129
self.therapySettings = therapySettings
127130
self.pumpSupportedIncrements = pumpSupportedIncrements
128131
self.syncPumpSchedule = syncPumpSchedule
132+
self.syncDeliveryLimits = syncDeliveryLimits
129133
self.sensitivityOverridesEnabled = sensitivityOverridesEnabled
130134
self.closedLoopPreference = initialDosingEnabled
131135
self.isClosedLoopAllowed = false

Loop/Views/SettingsView.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ extension SettingsView {
135135
viewModel: TherapySettingsViewModel(therapySettings: self.viewModel.therapySettings(),
136136
pumpSupportedIncrements: self.viewModel.pumpSupportedIncrements,
137137
syncPumpSchedule: self.viewModel.syncPumpSchedule,
138+
syncDeliveryLimits: self.viewModel.syncDeliveryLimits,
138139
sensitivityOverridesEnabled: FeatureFlags.sensitivityOverridesEnabled,
139140
didSave: self.viewModel.didSave))
140141
.environmentObject(displayGlucoseUnitObservable)
@@ -416,6 +417,7 @@ public struct SettingsView_Previews: PreviewProvider {
416417
therapySettings: { TherapySettings() },
417418
pumpSupportedIncrements: nil,
418419
syncPumpSchedule: nil,
420+
syncDeliveryLimits: nil,
419421
sensitivityOverridesEnabled: false,
420422
initialDosingEnabled: true,
421423
isClosedLoopAllowed: fakeClosedLoopAllowedPublisher.$mockIsClosedLoopAllowed,

LoopTests/Managers/DoseEnactorTests.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ extension MockPumpManagerError: LocalizedError {
2424
class MockPumpManager: PumpManager {
2525

2626
var enactBolusCalled: ((Double, Bool) -> Void)?
27+
2728
var enactTempBasalCalled: ((Double, TimeInterval) -> Void)?
2829

2930
var enactTempBasalError: PumpManagerError?
@@ -105,7 +106,11 @@ class MockPumpManager: PumpManager {
105106

106107
func syncBasalRateSchedule(items scheduleItems: [RepeatingScheduleValue<Double>], completion: @escaping (Result<BasalRateSchedule, Error>) -> Void) {
107108
}
108-
109+
110+
func syncDeliveryLimits(limits deliveryLimits: DeliveryLimits, completion: @escaping (Result<DeliveryLimits, Error>) -> Void) {
111+
112+
}
113+
109114
var managerIdentifier: String = "MockPumpManager"
110115

111116
var localizedTitle: String = "MockPumpManager"

0 commit comments

Comments
 (0)