CREditorProvider.swift 569 B

12345678910111213141516
  1. import Combine
  2. extension CREditor {
  3. final class Provider: BaseProvider, CREditorProvider {
  4. var profile: CarbRatios {
  5. (try? storage.retrieve(OpenAPS.Settings.carbRatios, as: CarbRatios.self))
  6. ?? CarbRatios(from: OpenAPS.defaults(for: OpenAPS.Settings.carbRatios))
  7. ?? CarbRatios(units: .grams, schedule: [CarbRatioEntry(start: "00:00:00", offset: 0, ratio: 10)])
  8. }
  9. func saveProfile(_ profile: CarbRatios) {
  10. try? storage.save(profile, as: OpenAPS.Settings.carbRatios)
  11. }
  12. }
  13. }