|
9 | 9 | import Foundation |
10 | 10 | import LoopKit |
11 | 11 | import HealthKit |
12 | | -import MinimedKit |
13 | | -import RileyLinkKit |
14 | 12 |
|
15 | 13 |
|
16 | 14 | extension UserDefaults { |
17 | 15 |
|
18 | 16 | private enum Key: String { |
19 | 17 | case basalRateSchedule = "com.loudnate.Naterade.BasalRateSchedule" |
20 | 18 | case carbRatioSchedule = "com.loudnate.Naterade.CarbRatioSchedule" |
21 | | - case connectedPeripheralIDs = "com.loudnate.Naterade.ConnectedPeripheralIDs" |
22 | 19 | case insulinModelSettings = "com.loopkit.Loop.insulinModelSettings" |
23 | 20 | case loopSettings = "com.loopkit.Loop.loopSettings" |
24 | 21 | case insulinSensitivitySchedule = "com.loudnate.Naterade.InsulinSensitivitySchedule" |
25 | | - case pumpSettings = "com.loopkit.Loop.PumpSettings" |
26 | | - case pumpState = "com.loopkit.Loop.PumpState" |
27 | 22 | } |
28 | 23 |
|
29 | 24 | var basalRateSchedule: BasalRateSchedule? { |
@@ -52,15 +47,6 @@ extension UserDefaults { |
52 | 47 | } |
53 | 48 | } |
54 | 49 |
|
55 | | - var connectedPeripheralIDs: [String] { |
56 | | - get { |
57 | | - return array(forKey: Key.connectedPeripheralIDs.rawValue) as? [String] ?? [] |
58 | | - } |
59 | | - set { |
60 | | - set(newValue, forKey: Key.connectedPeripheralIDs.rawValue) |
61 | | - } |
62 | | - } |
63 | | - |
64 | 50 | var insulinModelSettings: InsulinModelSettings? { |
65 | 51 | get { |
66 | 52 | if let rawValue = dictionary(forKey: Key.insulinModelSettings.rawValue) { |
@@ -150,70 +136,4 @@ extension UserDefaults { |
150 | 136 | set(newValue?.rawValue, forKey: Key.insulinSensitivitySchedule.rawValue) |
151 | 137 | } |
152 | 138 | } |
153 | | - |
154 | | - var pumpSettings: PumpSettings? { |
155 | | - get { |
156 | | - if let raw = dictionary(forKey: Key.pumpSettings.rawValue) { |
157 | | - return PumpSettings(rawValue: raw) |
158 | | - } else { |
159 | | - // Migrate the version 0 case |
160 | | - let standard = UserDefaults.standard |
161 | | - defer { |
162 | | - standard.removeObject(forKey: "com.loudnate.Naterade.PumpID") |
163 | | - standard.removeObject(forKey: "com.loopkit.Loop.PumpRegion") |
164 | | - } |
165 | | - |
166 | | - guard let pumpID = standard.string(forKey: "com.loudnate.Naterade.PumpID") else { |
167 | | - return nil |
168 | | - } |
169 | | - |
170 | | - let settings = PumpSettings( |
171 | | - pumpID: pumpID, |
172 | | - // Defaults to 0 / northAmerica |
173 | | - pumpRegion: PumpRegion(rawValue: standard.integer(forKey: "com.loopkit.Loop.PumpRegion")) |
174 | | - ) |
175 | | - |
176 | | - self.pumpSettings = settings |
177 | | - |
178 | | - return settings |
179 | | - } |
180 | | - } |
181 | | - set { |
182 | | - set(newValue?.rawValue, forKey: Key.pumpSettings.rawValue) |
183 | | - } |
184 | | - } |
185 | | - |
186 | | - var pumpState: PumpState? { |
187 | | - get { |
188 | | - if let raw = dictionary(forKey: Key.pumpState.rawValue) { |
189 | | - return PumpState(rawValue: raw) |
190 | | - } else { |
191 | | - // Migrate the version 0 case |
192 | | - let standard = UserDefaults.standard |
193 | | - defer { |
194 | | - standard.removeObject(forKey: "com.loudnate.Naterade.PumpModelNumber") |
195 | | - standard.removeObject(forKey: "com.loudnate.Naterade.PumpTimeZone") |
196 | | - } |
197 | | - |
198 | | - var state = PumpState() |
199 | | - |
200 | | - if let pumpModelNumber = standard.string(forKey: "com.loudnate.Naterade.PumpModelNumber") { |
201 | | - state.pumpModel = PumpModel(rawValue: pumpModelNumber) |
202 | | - } |
203 | | - |
204 | | - if let offset = standard.object(forKey: "com.loudnate.Naterade.PumpTimeZone") as? NSNumber, |
205 | | - let timeZone = TimeZone(secondsFromGMT: offset.intValue) |
206 | | - { |
207 | | - state.timeZone = timeZone |
208 | | - } |
209 | | - |
210 | | - self.pumpState = state |
211 | | - |
212 | | - return state |
213 | | - } |
214 | | - } |
215 | | - set { |
216 | | - set(newValue?.rawValue, forKey: Key.pumpState.rawValue) |
217 | | - } |
218 | | - } |
219 | 139 | } |
0 commit comments