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
20 changes: 10 additions & 10 deletions Loop.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -4573,7 +4573,7 @@
CODE_SIGN_IDENTITY = "$(LOOP_CODE_SIGN_IDENTITY_DEBUG)";
CODE_SIGN_STYLE = "$(LOOP_CODE_SIGN_STYLE)";
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_TEAM = UY678SP37Q;
DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = Loop/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
Expand All @@ -4595,7 +4595,7 @@
CODE_SIGN_ENTITLEMENTS = "$(LOOP_ENTITLEMENTS)";
CODE_SIGN_IDENTITY = "$(LOOP_CODE_SIGN_IDENTITY_RELEASE)";
CODE_SIGN_STYLE = "$(LOOP_CODE_SIGN_STYLE)";
DEVELOPMENT_TEAM = UY678SP37Q;
DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = Loop/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
Expand All @@ -4614,7 +4614,7 @@
CODE_SIGN_ENTITLEMENTS = "WatchApp Extension/WatchApp Extension.entitlements";
CODE_SIGN_IDENTITY = "$(LOOP_CODE_SIGN_IDENTITY_DEBUG)";
CODE_SIGN_STYLE = "$(LOOP_CODE_SIGN_STYLE)";
DEVELOPMENT_TEAM = UY678SP37Q;
DEVELOPMENT_TEAM = "";
FRAMEWORK_SEARCH_PATHS = "$(PROJECT_DIR)/Carthage/Build/watchOS";
INFOPLIST_FILE = "WatchApp Extension/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
Expand All @@ -4636,7 +4636,7 @@
CODE_SIGN_ENTITLEMENTS = "WatchApp Extension/WatchApp Extension.entitlements";
CODE_SIGN_IDENTITY = "$(LOOP_CODE_SIGN_IDENTITY_RELEASE)";
CODE_SIGN_STYLE = "$(LOOP_CODE_SIGN_STYLE)";
DEVELOPMENT_TEAM = UY678SP37Q;
DEVELOPMENT_TEAM = "";
FRAMEWORK_SEARCH_PATHS = "$(PROJECT_DIR)/Carthage/Build/watchOS";
INFOPLIST_FILE = "WatchApp Extension/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
Expand All @@ -4658,7 +4658,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = "$(APPICON_NAME)";
CODE_SIGN_IDENTITY = "$(LOOP_CODE_SIGN_IDENTITY_DEBUG)";
CODE_SIGN_STYLE = "$(LOOP_CODE_SIGN_STYLE)";
DEVELOPMENT_TEAM = UY678SP37Q;
DEVELOPMENT_TEAM = "";
FRAMEWORK_SEARCH_PATHS = "$(PROJECT_DIR)/Carthage/Build/watchOS";
IBSC_MODULE = WatchApp_Extension;
INFOPLIST_FILE = WatchApp/Info.plist;
Expand All @@ -4680,7 +4680,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = "$(APPICON_NAME)";
CODE_SIGN_IDENTITY = "$(LOOP_CODE_SIGN_IDENTITY_RELEASE)";
CODE_SIGN_STYLE = "$(LOOP_CODE_SIGN_STYLE)";
DEVELOPMENT_TEAM = UY678SP37Q;
DEVELOPMENT_TEAM = "";
FRAMEWORK_SEARCH_PATHS = "$(PROJECT_DIR)/Carthage/Build/watchOS";
IBSC_MODULE = WatchApp_Extension;
INFOPLIST_FILE = WatchApp/Info.plist;
Expand Down Expand Up @@ -4847,7 +4847,7 @@
CODE_SIGN_ENTITLEMENTS = "Loop Status Extension/Loop Status Extension.entitlements";
CODE_SIGN_IDENTITY = "$(LOOP_CODE_SIGN_IDENTITY_DEBUG)";
CODE_SIGN_STYLE = "$(LOOP_CODE_SIGN_STYLE)";
DEVELOPMENT_TEAM = UY678SP37Q;
DEVELOPMENT_TEAM = "";
ENABLE_BITCODE = NO;
INFOPLIST_FILE = "Loop Status Extension/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
Expand All @@ -4866,7 +4866,7 @@
CODE_SIGN_ENTITLEMENTS = "Loop Status Extension/Loop Status Extension.entitlements";
CODE_SIGN_IDENTITY = "$(LOOP_CODE_SIGN_IDENTITY_RELEASE)";
CODE_SIGN_STYLE = "$(LOOP_CODE_SIGN_STYLE)";
DEVELOPMENT_TEAM = UY678SP37Q;
DEVELOPMENT_TEAM = "";
ENABLE_BITCODE = NO;
INFOPLIST_FILE = "Loop Status Extension/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
Expand Down Expand Up @@ -4931,7 +4931,7 @@
CODE_SIGN_IDENTITY = "$(LOOP_CODE_SIGN_IDENTITY_DEBUG)";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 57;
DEVELOPMENT_TEAM = UY678SP37Q;
DEVELOPMENT_TEAM = "";
GCC_DYNAMIC_NO_PIC = NO;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
INFOPLIST_FILE = "Loop Intent Extension/Info.plist";
Expand Down Expand Up @@ -4968,7 +4968,7 @@
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 57;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_TEAM = UY678SP37Q;
DEVELOPMENT_TEAM = "";
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
INFOPLIST_FILE = "Loop Intent Extension/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,18 +88,16 @@
debugServiceExtension = "internal"
allowLocationSimulation = "YES"
launchAutomaticallySubstyle = "32">
<RemoteRunnable
runnableDebuggingMode = "2"
BundleIdentifier = "com.apple.Carousel"
RemotePath = "/$(MAIN_APP_DISPLAY_NAME)">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "43A943711B926B7B0051FA24"
BuildableName = "WatchApp.app"
BlueprintName = "WatchApp"
ReferencedContainer = "container:Loop.xcodeproj">
</BuildableReference>
</RemoteRunnable>
</BuildableProductRunnable>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
Expand All @@ -108,27 +106,16 @@
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES"
launchAutomaticallySubstyle = "32">
<RemoteRunnable
runnableDebuggingMode = "2"
BundleIdentifier = "com.apple.Carousel"
RemotePath = "/$(MAIN_APP_DISPLAY_NAME)">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "43A943711B926B7B0051FA24"
BuildableName = "WatchApp.app"
BlueprintName = "WatchApp"
ReferencedContainer = "container:Loop.xcodeproj">
</BuildableReference>
</RemoteRunnable>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "43A943711B926B7B0051FA24"
BuildableName = "WatchApp.app"
BlueprintName = "WatchApp"
ReferencedContainer = "container:Loop.xcodeproj">
</BuildableReference>
</MacroExpansion>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,18 +89,16 @@
allowLocationSimulation = "YES"
launchAutomaticallySubstyle = "8"
notificationPayloadFile = "WatchApp Extension/PushNotificationPayload.apns">
<RemoteRunnable
runnableDebuggingMode = "2"
BundleIdentifier = "com.apple.Carousel"
RemotePath = "/$(MAIN_APP_DISPLAY_NAME)">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "43A943711B926B7B0051FA24"
BuildableName = "WatchApp.app"
BlueprintName = "WatchApp"
ReferencedContainer = "container:Loop.xcodeproj">
</BuildableReference>
</RemoteRunnable>
</BuildableProductRunnable>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
Expand All @@ -110,27 +108,16 @@
debugDocumentVersioning = "YES"
launchAutomaticallySubstyle = "8"
notificationPayloadFile = "WatchApp Extension/PushNotificationPayload.apns">
<RemoteRunnable
runnableDebuggingMode = "2"
BundleIdentifier = "com.apple.Carousel"
RemotePath = "/$(MAIN_APP_DISPLAY_NAME)">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "43A943711B926B7B0051FA24"
BuildableName = "WatchApp.app"
BlueprintName = "WatchApp"
ReferencedContainer = "container:Loop.xcodeproj">
</BuildableReference>
</RemoteRunnable>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "43A943711B926B7B0051FA24"
BuildableName = "WatchApp.app"
BlueprintName = "WatchApp"
ReferencedContainer = "container:Loop.xcodeproj">
</BuildableReference>
</MacroExpansion>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
Expand Down
25 changes: 6 additions & 19 deletions Loop.xcodeproj/xcshareddata/xcschemes/WatchApp.xcscheme
Original file line number Diff line number Diff line change
Expand Up @@ -88,18 +88,16 @@
debugServiceExtension = "internal"
allowLocationSimulation = "YES"
notificationPayloadFile = "WatchApp Extension/PushNotificationPayload.apns">
<RemoteRunnable
runnableDebuggingMode = "2"
BundleIdentifier = "com.apple.Carousel"
RemotePath = "/$(MAIN_APP_DISPLAY_NAME)">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "43A943711B926B7B0051FA24"
BuildableName = "WatchApp.app"
BlueprintName = "WatchApp"
ReferencedContainer = "container:Loop.xcodeproj">
</BuildableReference>
</RemoteRunnable>
</BuildableProductRunnable>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
Expand All @@ -108,27 +106,16 @@
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES"
notificationPayloadFile = "WatchApp Extension/PushNotificationPayload.apns">
<RemoteRunnable
runnableDebuggingMode = "2"
BundleIdentifier = "com.apple.Carousel"
RemotePath = "/$(MAIN_APP_DISPLAY_NAME)">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "43A943711B926B7B0051FA24"
BuildableName = "WatchApp.app"
BlueprintName = "WatchApp"
ReferencedContainer = "container:Loop.xcodeproj">
</BuildableReference>
</RemoteRunnable>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "43A943711B926B7B0051FA24"
BuildableName = "WatchApp.app"
BlueprintName = "WatchApp"
ReferencedContainer = "container:Loop.xcodeproj">
</BuildableReference>
</MacroExpansion>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
Expand Down
2 changes: 1 addition & 1 deletion Loop/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ extension AppDelegate: UNUserNotificationCenterDelegate {
{
deviceDataManager?.analyticsServicesManager.didRetryBolus()

deviceDataManager?.enactBolus(units: units, at: startDate) { (_) in
deviceDataManager?.enactBolus(units: units, automatic: false) { (_) in
completionHandler()
}
return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ extension DeviceDataManager: BolusEntryViewModelDelegate, LoggedDoseViewModelDel
loopManager.storeBolusDosingDecision(bolusDosingDecision, withDate: date)
}

/// func enactBolus(units: Double, at startDate: Date, completion: @escaping (_ error: Error?) -> Void)
/// is already implemented in DeviceDataManager

func getGlucoseSamples(start: Date?, end: Date?, completion: @escaping (Swift.Result<[StoredGlucoseSample], Error>) -> Void) {
glucoseStore.getGlucoseSamples(start: start, end: end, completion: completion)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ extension DeviceDataManager: SimpleBolusViewModelDelegate {
}
}

func enactBolus(units: Double, at startDate: Date) {
enactBolus(units: units, at: startDate) { (_) in }
func enactBolus(units: Double, automatic: Bool) {
enactBolus(units: units, automatic: automatic) { (_) in }
}

func computeSimpleBolusRecommendation(at date: Date, mealCarbs: HKQuantity?, manualGlucose: HKQuantity?) -> BolusDosingDecision? {
Expand Down
6 changes: 4 additions & 2 deletions Loop/Extensions/DoseStore+SimulatedCoreData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,8 @@ fileprivate extension PersistedPumpEvent {
raw: Data(UUID().uuidString.utf8),
title: UUID().uuidString,
type: type,
isMutable: false)
isMutable: false,
automatic: nil)
}

private static func simulated(dose: DoseEntry) -> PersistedPumpEvent {
Expand All @@ -203,6 +204,7 @@ fileprivate extension PersistedPumpEvent {
raw: Data(UUID().uuidString.utf8),
title: String(describing: dose),
type: dose.type.pumpEventType!,
isMutable: false)
isMutable: false,
automatic: nil)
}
}
14 changes: 5 additions & 9 deletions Loop/Managers/DeviceDataManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -580,23 +580,19 @@ private extension DeviceDataManager {

// MARK: - Client API
extension DeviceDataManager {
func enactBolus(units: Double, at startDate: Date = Date(), completion: @escaping (_ error: Error?) -> Void = { _ in }) {
func enactBolus(units: Double, automatic: Bool, completion: @escaping (_ error: Error?) -> Void = { _ in }) {
guard let pumpManager = pumpManager else {
completion(LoopError.configurationError(.pumpManager))
return
}

self.loopManager.addRequestedBolus(DoseEntry(type: .bolus, startDate: Date(), value: units, unit: .units), completion: nil)
pumpManager.enactBolus(units: units, at: startDate) { (result) in
pumpManager.enactBolus(units: units, automatic: automatic) { (result) in
switch result {
case .failure(let error):
self.log.error("%{public}@", String(describing: error))
switch error {
case .uncertainDelivery:
// Do not generate notification on uncertain delivery error
break
default:
NotificationManager.sendBolusFailureNotification(for: error, units: units, at: startDate)
if case .uncertainDelivery = error, !automatic {
NotificationManager.sendBolusFailureNotification(for: error, units: units, at: Date())
}
self.loopManager.bolusRequestFailed(error) {
completion(error)
Expand Down Expand Up @@ -1147,7 +1143,7 @@ extension DeviceDataManager: LoopDataManagerDelegate {
if automaticDose.recommendation.bolusUnits > 0 {
self.log.default("LoopManager did recommend bolus dose")
doseDispatchGroup.enter()
pumpManager.enactBolus(units: automaticDose.recommendation.bolusUnits, at: Date()) { (result) in
pumpManager.enactBolus(units: automaticDose.recommendation.bolusUnits, automatic: true) { (result) in
switch result {
case .failure(let error):
bolusError = error
Expand Down
2 changes: 1 addition & 1 deletion Loop/Managers/WatchDataManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ final class WatchDataManager: NSObject {
return
}

deviceManager.enactBolus(units: bolus.value, at: bolus.startDate) { (error) in
deviceManager.enactBolus(units: bolus.value, automatic: true) { (error) in
if error == nil {
self.deviceManager.analyticsServicesManager.didSetBolusFromWatch(bolus.value)
}
Expand Down
4 changes: 2 additions & 2 deletions Loop/View Models/BolusEntryViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ protocol BolusEntryViewModelDelegate: class {

func storeBolusDosingDecision(_ bolusDosingDecision: BolusDosingDecision, withDate date: Date)

func enactBolus(units: Double, at startDate: Date, completion: @escaping (_ error: Error?) -> Void)
func enactBolus(units: Double, automatic: Bool, completion: @escaping (_ error: Error?) -> Void)

func logOutsideInsulinDose(startDate: Date, units: Double, insulinType: InsulinType?)

Expand Down Expand Up @@ -379,7 +379,7 @@ final class BolusEntryViewModel: ObservableObject {
isInitiatingSaveOrBolus = true
savedPreMealOverride = nil
// TODO: should we pass along completion or not???
delegate?.enactBolus(units: bolusVolume, at: now, completion: { _ in })
delegate?.enactBolus(units: bolusVolume, automatic: false, completion: { _ in })
completion()
}

Expand Down
4 changes: 2 additions & 2 deletions Loop/View Models/SimpleBolusViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ protocol SimpleBolusViewModelDelegate: class {

func storeBolusDosingDecision(_ bolusDosingDecision: BolusDosingDecision, withDate date: Date)

func enactBolus(units: Double, at startDate: Date)
func enactBolus(units: Double, automatic: Bool)

func insulinOnBoard(at date: Date, completion: @escaping (_ result: DoseStoreResult<InsulinValue>) -> Void)

Expand Down Expand Up @@ -306,7 +306,7 @@ class SimpleBolusViewModel: ObservableObject {

func enactBolus() {
if let bolusVolume = bolus?.doubleValue(for: .internationalUnit()), bolusVolume > 0 {
delegate.enactBolus(units: bolusVolume, at: saveDate)
delegate.enactBolus(units: bolusVolume, automatic: false)
dosingDecision?.requestedBolus = bolusVolume
}
}
Expand Down
2 changes: 1 addition & 1 deletion Loop/Views/SimpleBolusView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ struct SimpleBolusCalculatorView_Previews: PreviewProvider {
completion(.success(storedCarbEntry))
}

func enactBolus(units: Double, at startDate: Date) {
func enactBolus(units: Double, automatic: Bool) {
}

func insulinOnBoard(at date: Date, completion: @escaping (DoseStoreResult<InsulinValue>) -> Void) {
Expand Down
Loading