Skip to content

Commit

Permalink
Resolve a type error (Artificial-Pancreas#935)
Browse files Browse the repository at this point in the history
Resolves a Preferences type error.

CAVE! This will reset Preferences.json to defaults, but if you have backup of settings enabled (sharing) you will have the option to restore the settings with just a tap in a confirmation dialogue, no key needed.
  • Loading branch information
Jon-b-m authored Nov 11, 2024
1 parent e3149b5 commit c8d57c9
Show file tree
Hide file tree
Showing 13 changed files with 278 additions and 85 deletions.
2 changes: 1 addition & 1 deletion Config.xcconfig
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
APP_DISPLAY_NAME = iAPS
APP_VERSION = 5.7.0
APP_VERSION = 5.7.1
APP_BUILD_NUMBER = 1
COPYRIGHT_NOTICE =
DEVELOPER_TEAM = ##TEAM_ID##
Expand Down
56 changes: 46 additions & 10 deletions FreeAPS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
0F7A65FBD2CD8D6477ED4539 /* NotificationsConfigProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = E625985B47742D498CB1681A /* NotificationsConfigProvider.swift */; };
17A9D0899046B45E87834820 /* CREditorProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9C8D5F457B5AFF763F8CF3DF /* CREditorProvider.swift */; };
19012CDC291D2CB900FB8210 /* LoopStats.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19012CDB291D2CB900FB8210 /* LoopStats.swift */; };
1901412D2CDB92D600ABD925 /* RestoreDataFlow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1901412C2CDB92CB00ABD925 /* RestoreDataFlow.swift */; };
1901412F2CDB92F200ABD925 /* RestoreProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1901412E2CDB92E600ABD925 /* RestoreProvider.swift */; };
190141312CDB930400ABD925 /* RestoreStateModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 190141302CDB92FB00ABD925 /* RestoreStateModel.swift */; };
190141342CDB931A00ABD925 /* RestoreRootView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 190141332CDB931000ABD925 /* RestoreRootView.swift */; };
190141362CDB9D4B00ABD925 /* Token.swift in Sources */ = {isa = PBXBuildFile; fileRef = 190141352CDB9D4600ABD925 /* Token.swift */; };
190EBCC429FF136900BA767D /* StatConfigDataFlow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 190EBCC329FF136900BA767D /* StatConfigDataFlow.swift */; };
190EBCC629FF138000BA767D /* StatConfigProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 190EBCC529FF138000BA767D /* StatConfigProvider.swift */; };
190EBCC829FF13AA00BA767D /* StatConfigStateModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 190EBCC729FF13AA00BA767D /* StatConfigStateModel.swift */; };
Expand Down Expand Up @@ -563,6 +568,11 @@
10A0C32B0DAB52726EF9B6D9 /* BolusRootView.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = BolusRootView.swift; sourceTree = "<group>"; };
12204445D7632AF09264A979 /* PreferencesEditorDataFlow.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = PreferencesEditorDataFlow.swift; sourceTree = "<group>"; };
19012CDB291D2CB900FB8210 /* LoopStats.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoopStats.swift; sourceTree = "<group>"; };
1901412C2CDB92CB00ABD925 /* RestoreDataFlow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RestoreDataFlow.swift; sourceTree = "<group>"; };
1901412E2CDB92E600ABD925 /* RestoreProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RestoreProvider.swift; sourceTree = "<group>"; };
190141302CDB92FB00ABD925 /* RestoreStateModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RestoreStateModel.swift; sourceTree = "<group>"; };
190141332CDB931000ABD925 /* RestoreRootView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RestoreRootView.swift; sourceTree = "<group>"; };
190141352CDB9D4600ABD925 /* Token.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Token.swift; sourceTree = "<group>"; };
190EBCC329FF136900BA767D /* StatConfigDataFlow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StatConfigDataFlow.swift; sourceTree = "<group>"; };
190EBCC529FF138000BA767D /* StatConfigProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StatConfigProvider.swift; sourceTree = "<group>"; };
190EBCC729FF13AA00BA767D /* StatConfigStateModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StatConfigStateModel.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1171,6 +1181,25 @@
path = View;
sourceTree = "<group>";
};
1901412B2CDB92B500ABD925 /* Restore */ = {
isa = PBXGroup;
children = (
1901412C2CDB92CB00ABD925 /* RestoreDataFlow.swift */,
1901412E2CDB92E600ABD925 /* RestoreProvider.swift */,
190141302CDB92FB00ABD925 /* RestoreStateModel.swift */,
190141322CDB930800ABD925 /* View */,
);
path = Restore;
sourceTree = "<group>";
};
190141322CDB930800ABD925 /* View */ = {
isa = PBXGroup;
children = (
190141332CDB931000ABD925 /* RestoreRootView.swift */,
);
path = View;
sourceTree = "<group>";
};
190EBCC229FF134900BA767D /* StatConfig */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -1407,28 +1436,24 @@
3811DE0325C9D31700A708ED /* Modules */ = {
isa = PBXGroup;
children = (
F2159A472BA60A0300A0B716 /* ContactTrick */,
19F191D92BE4F93400F6297E /* Sharing */,
195D80B22AF696EE00D25097 /* Dynamic */,
190EBCC229FF134900BA767D /* StatConfig */,
BD7DA9A32AE06DBA00601B20 /* BolusCalculatorConfig */,
19F95FF129F10F9C00314DDC /* Stat */,
CE94597C29E9E1CD0047C9C6 /* WatchConfig */,
19E1F7E629D0828B005C8D20 /* IconConfig */,
19D466A129AA2B0A004D5F33 /* FPUConfig */,
F90692CD274B99850037068D /* HealthKit */,
6DC5D590658EF8B8DF94F9F5 /* AddCarbs */,
A9A4C88374496B3C89058A89 /* AddTempTarget */,
672F63EEAE27400625E14BAD /* AutotuneConfig */,
A42F1FEDFFD0DDE00AAD54D3 /* BasalProfileEditor */,
3811DE0425C9D32E00A708ED /* Base */,
C2C98283C436DB934D7E7994 /* Bolus */,
BD7DA9A32AE06DBA00601B20 /* BolusCalculatorConfig */,
E8176B120B55CE89F1591542 /* Calibrations */,
F75CB57ED6971B46F8756083 /* CGM */,
0610F7D6D2EC00E3BA1569F0 /* ConfigEditor */,
F2159A472BA60A0300A0B716 /* ContactTrick */,
E42231DBF0DBE2B4B92D1B15 /* CREditor */,
9E56E3626FAD933385101B76 /* DataTable */,
195D80B22AF696EE00D25097 /* Dynamic */,
19D466A129AA2B0A004D5F33 /* FPUConfig */,
F90692CD274B99850037068D /* HealthKit */,
3811DE2725C9D49500A708ED /* Home */,
19E1F7E629D0828B005C8D20 /* IconConfig */,
D8F047E14D567F2B5DBEFD96 /* ISFEditor */,
C11D545CED3ECEB525EDEE23 /* LibreConfig */,
3811DE1A25C9D48300A708ED /* Main */,
Expand All @@ -1439,9 +1464,14 @@
3E1C41D9301B7058AA7BF5EA /* PreferencesEditor */,
99C01B871ACAB3F32CE755C7 /* PumpConfig */,
E493126EA71765130F64CCE5 /* PumpSettingsEditor */,
1901412B2CDB92B500ABD925 /* Restore */,
3811DE3825C9D4A100A708ED /* Settings */,
19F191D92BE4F93400F6297E /* Sharing */,
29B478DF61BF8D270F7D8954 /* Snooze */,
19F95FF129F10F9C00314DDC /* Stat */,
190EBCC229FF134900BA767D /* StatConfig */,
6517011F19F244F64E1FF14B /* TargetsEditor */,
CE94597C29E9E1CD0047C9C6 /* WatchConfig */,
);
path = Modules;
sourceTree = "<group>";
Expand Down Expand Up @@ -1894,6 +1924,7 @@
388E5A5A25B6F05F0019842D /* Helpers */ = {
isa = PBXGroup;
children = (
190141352CDB9D4600ABD925 /* Token.swift */,
FEFA5C10299F814A00765C17 /* CoreDataStack.swift */,
38F37827261260DC009DB701 /* Color+Extensions.swift */,
389ECE042601144100D86C4F /* ConcurrentMap.swift */,
Expand Down Expand Up @@ -2924,6 +2955,7 @@
38C4D33725E9A1A300D30B77 /* DispatchQueue+Extensions.swift in Sources */,
F90692CF274B999A0037068D /* HealthKitDataFlow.swift in Sources */,
CE7CA3552A064973004BE681 /* ListStateIntent.swift in Sources */,
190141362CDB9D4B00ABD925 /* Token.swift in Sources */,
19F191DE2BE4F97F00F6297E /* SharingProvider.swift in Sources */,
195D80B72AF697B800D25097 /* DynamicDataFlow.swift in Sources */,
3862CC2E2743F9F700BF832C /* CalendarManager.swift in Sources */,
Expand Down Expand Up @@ -2979,6 +3011,7 @@
38569348270B5DFB0002C50D /* GlucoseSource.swift in Sources */,
CEB434E328B8F9DB00B70274 /* BluetoothStateManager.swift in Sources */,
3811DE4225C9D4A100A708ED /* SettingsDataFlow.swift in Sources */,
1901412D2CDB92D600ABD925 /* RestoreDataFlow.swift in Sources */,
3811DE2525C9D48300A708ED /* MainRootView.swift in Sources */,
CE94598229E9E3D30047C9C6 /* WatchConfigProvider.swift in Sources */,
191A9D162BED00A500028D48 /* Version.swift in Sources */,
Expand All @@ -2998,6 +3031,7 @@
1920BF5D2B9DF53200E861FE /* BolusShortcut.swift in Sources */,
38A13D3225E28B4B00EAA382 /* PumpHistoryEvent.swift in Sources */,
E00EEC0627368630002FF094 /* UIAssembly.swift in Sources */,
1901412F2CDB92F200ABD925 /* RestoreProvider.swift in Sources */,
3811DE1825C9D40400A708ED /* Router.swift in Sources */,
CE7950262998056D00FA576E /* CGMSetupView.swift in Sources */,
38A0363B25ECF07E00FCBB52 /* GlucoseStorage.swift in Sources */,
Expand Down Expand Up @@ -3066,6 +3100,7 @@
3811DE3F25C9D4A100A708ED /* SettingsStateModel.swift in Sources */,
CE7CA3582A064E2F004BE681 /* ListStateView.swift in Sources */,
193F6CDD2A512C8F001240FD /* Loops.swift in Sources */,
190141342CDB931A00ABD925 /* RestoreRootView.swift in Sources */,
38B4F3CB25E502E200E76A18 /* WeakObjectSet.swift in Sources */,
38E989DD25F5021400C0CED0 /* PumpStatus.swift in Sources */,
BDFD165A2AE40438007F0DDA /* AlternativeBolusCalcRootView.swift in Sources */,
Expand Down Expand Up @@ -3099,6 +3134,7 @@
19AEF4322B1F5A98006FFE8B /* TIRView.swift in Sources */,
38A43598262E0E4900E80935 /* FetchAnnouncementsManager.swift in Sources */,
642F76A05A4FF530463A9FD0 /* NightscoutConfigRootView.swift in Sources */,
190141312CDB930400ABD925 /* RestoreStateModel.swift in Sources */,
190F8CF72BC6F70800EDB473 /* IllustrationView.swift in Sources */,
19DB70A72BF8F01E00C05381 /* ActiveCOBView.swift in Sources */,
BD7DA9AC2AE06EB900601B20 /* BolusCalculatorConfigRootView.swift in Sources */,
Expand Down
4 changes: 0 additions & 4 deletions FreeAPS/Resources/javascript/prepare/profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,6 @@ function generate(pumpsettings_data, bgtargets_data, isf_data, basalprofile_data
Math.max(35, Math.min(preferences.insulinPeakTime, 100));
} else { preferences.insulinPeakTime = 55; }
}
// Migrate missing conversion from original freeaps
if (preferences.resistanceLowersTarget) {
preferences.resistance_lowers_target = true;
}
}

var tdd_factor = { };
Expand Down
14 changes: 14 additions & 0 deletions FreeAPS/Sources/Helpers/Token.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import Foundation

final class Token {
func getIdentifier() -> String {
let keychain = BaseKeychain()
var identfier = keychain.getValue(String.self, forKey: IAPSconfig.id) ?? ""
guard identfier.count > 1 else {
identfier = UUID().uuidString
keychain.setValue(identfier, forKey: IAPSconfig.id)
return identfier
}
return identfier
}
}
2 changes: 1 addition & 1 deletion FreeAPS/Sources/Models/Preferences.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ extension Preferences {
case highTemptargetRaisesSensitivity = "high_temptarget_raises_sensitivity"
case lowTemptargetLowersSensitivity = "low_temptarget_lowers_sensitivity"
case sensitivityRaisesTarget = "sensitivity_raises_target"
case resistanceLowersTarget
case resistanceLowersTarget = "resistance_lowers_target"
case advTargetAdjustments = "adv_target_adjustments"
case exerciseMode = "exercise_mode"
case halfBasalExerciseTarget = "half_basal_exercise_target"
Expand Down
19 changes: 19 additions & 0 deletions FreeAPS/Sources/Modules/Home/HomeStateModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ extension Home {
@Injected() var apsManager: APSManager!
@Injected() var nightscoutManager: NightscoutManager!
@Injected() var storage: TempTargetsStorage!
@Injected() var keychain: Keychain!
private let timer = DispatchTimer(timeInterval: 5)
private(set) var filteredHours = 24
@Published var glucose: [BloodGlucose] = []
Expand Down Expand Up @@ -91,6 +92,7 @@ extension Home {
@Published var tddActualAverage: Decimal = 0
@Published var skipGlucoseChart: Bool = false
@Published var displayDelta: Bool = false
@Published var openAPSSettings: Preferences?

let coredataContext = CoreDataStack.shared.persistentContainer.viewContext

Expand Down Expand Up @@ -306,6 +308,23 @@ extension Home {
}
}

func fetchPreferences() {
let token = Token().getIdentifier()
let database = Database(token: token)
database.fetchPreferences("default")
.receive(on: DispatchQueue.main)
.sink { completion in
switch completion {
case .finished:
debug(.service, "Preferences fetched from database. Profile: default")
case let .failure(error):
debug(.service, "Preferences fetched from database failed. Error: " + error.localizedDescription)
}
}
receiveValue: { self.openAPSSettings = $0 }
.store(in: &lifetime)
}

private func setupGlucose() {
DispatchQueue.main.async { [weak self] in
guard let self = self else { return }
Expand Down
Loading

0 comments on commit c8d57c9

Please sign in to comment.