-
Notifications
You must be signed in to change notification settings - Fork 4
[LOOP-5405] Activity Presets Core #688
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
Changes from all commits
809f383
dd4157d
0069282
3cbc728
f15d810
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,11 +64,8 @@ public struct ActivityPreset: Hashable, Identifiable, Sendable, RawRepresentable | |
} | ||
} | ||
|
||
private var defaultDuration: TemporaryScheduleOverride.Duration { | ||
.finite(.hours(1)) | ||
} | ||
|
||
public var defaultPreset: TemporaryPreset { | ||
public func defaultPreset(duration: TemporaryScheduleOverride.Duration) -> TemporaryPreset { | ||
TemporaryPreset( | ||
id: id, | ||
symbol: symbol, | ||
|
@@ -77,7 +74,7 @@ public struct ActivityPreset: Hashable, Identifiable, Sendable, RawRepresentable | |
targetRange: defaultTargetRange, | ||
insulinNeedsScaleFactor: defaultInsulinNeedsScaleFactor | ||
), | ||
duration: defaultDuration | ||
duration: duration | ||
) | ||
} | ||
} | ||
|
@@ -111,7 +108,7 @@ public struct ActivityPreset: Hashable, Identifiable, Sendable, RawRepresentable | |
} | ||
|
||
public var isModifiedFromDefault: Bool { | ||
preset != activityType.defaultPreset | ||
preset != activityType.defaultPreset(duration: preset.duration) | ||
} | ||
|
||
public var id: String { | ||
|
@@ -365,6 +362,8 @@ extension TemporaryScheduleOverride.Context: Codable { | |
self = .preMeal | ||
case CodableKeys.custom.rawValue: | ||
self = .custom | ||
case "legacyWorkout": | ||
self = .custom | ||
Comment on lines
+365
to
+366
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If a legacy workout is found when trying to decode, I just have it marked as custom here. I think ideally, this would decode into a .preset(TemporaryPreset), but I'm not sure what settings I'd provide it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is ok as is. |
||
default: | ||
throw DecodingError.dataCorrupted(DecodingError.Context(codingPath: decoder.codingPath, debugDescription: "invalid enumeration")) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is to support migration from the old preset symbol type to the new one.