Skip to content

Commit 9701d18

Browse files
committed
[LOOP-4596] Scenario Organization
1 parent 6489af2 commit 9701d18

File tree

6 files changed

+15
-7
lines changed

6 files changed

+15
-7
lines changed

Loop/Managers/Alerts/AlertManager.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -782,7 +782,7 @@ extension AlertManager {
782782
let alert = UIAlertController(title: "New Study Product Detected", message: "We've detected a new study product is selected. In order to show use this study product, Tidepool Loop will need to restart.", preferredStyle: .alert)
783783
alert.addAction(UIAlertAction(title: "Confirm", style: .default, handler: { _ in
784784
confirmAction()
785-
exit(0)
785+
fatalError("DEBUG: Resetting Loop")
786786
}))
787787
alert.addAction(UIAlertAction(title: "Cancel", style: .cancel))
788788

Loop/Managers/LocalTestingScenariosManager.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ final class LocalTestingScenariosManager: TestingScenariosManagerRequirements, D
3030
delegate?.testingScenariosManager(self, didUpdateScenarioURLs: scenarioURLs)
3131
}
3232
}
33+
34+
var pluginManager: PluginManager {
35+
deviceManager.pluginManager
36+
}
3337

3438
init(deviceManager: DeviceDataManager) {
3539
guard FeatureFlags.scenariosEnabled else {
@@ -63,7 +67,6 @@ final class LocalTestingScenariosManager: TestingScenariosManagerRequirements, D
6367
do {
6468
let scenarioURLs = try fileManager.contentsOfDirectory(at: scenariosSource, includingPropertiesForKeys: nil)
6569
.filter { $0.pathExtension == "json" }
66-
.sorted(by: { $0.lastPathComponent < $1.lastPathComponent })
6770
self.scenarioURLs = scenarioURLs
6871
delegate?.testingScenariosManager(self, didUpdateScenarioURLs: scenarioURLs)
6972
log.debug("Reloaded scenario URLs")

Loop/Managers/OnboardingManager.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,6 @@ extension OnboardingManager: TherapySettingsProvider {
435435

436436
extension OnboardingManager: OnboardingProvider {
437437
var allowDebugFeatures: Bool { FeatureFlags.allowDebugFeatures } // NOTE: DEBUG FEATURES - DEBUG AND TEST ONLY
438-
var studyProductSelection: StudyProduct { StudyProduct(rawValue: UserDefaults.appGroup?.studyProductSelection ?? "none") ?? .none }
439438
}
440439

441440
// MARK: - OnboardingUI

Loop/Managers/TestingScenariosManager.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ protocol TestingScenariosManager: AnyObject {
1818
var delegate: TestingScenariosManagerDelegate? { get set }
1919
var activeScenarioURL: URL? { get }
2020
var scenarioURLs: [URL] { get }
21+
var pluginManager: PluginManager { get }
2122
func loadScenario(from url: URL, completion: @escaping (Error?) -> Void)
2223
func loadScenario(from url: URL, advancedByLoopIterations iterations: Int, completion: @escaping (Error?) -> Void)
2324
func loadScenario(from url: URL, rewoundByLoopIterations iterations: Int, completion: @escaping (Error?) -> Void)

Loop/View Controllers/TestingScenariosTableViewController.swift

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,13 @@ final class TestingScenariosTableViewController: RadioSelectionTableViewControll
170170

171171
extension TestingScenariosTableViewController: TestingScenariosManagerDelegate {
172172
func testingScenariosManager(_ manager: TestingScenariosManager, didUpdateScenarioURLs scenarioURLs: [URL]) {
173-
let rawStudyProduct = UserDefaults.appGroup?.studyProductSelection ?? "none"
174-
let studyProduct = StudyProduct(rawValue: rawStudyProduct) ?? .none
175-
self.scenarioURLs = studyProduct.filtered(scenarioURLs: scenarioURLs)
173+
var filteredURLs = Set<URL>()
174+
manager.pluginManager.availableSupports.forEach { supportUI in
175+
supportUI.filterScenarios(scenarioURLs: scenarioURLs).forEach { scenarioURL in
176+
filteredURLs.insert(scenarioURL)
177+
}
178+
}
179+
180+
self.scenarioURLs = Array(filteredURLs).sorted(by: { $0.lastPathComponent < $1.lastPathComponent })
176181
}
177182
}

LoopCore/NSUserDefaults.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ extension UserDefaults {
2020
case lastProfileExpirationAlertDate = "com.loopkit.Loop.lastProfileExpirationAlertDate"
2121
case allowDebugFeatures = "com.loopkit.Loop.allowDebugFeatures"
2222
case allowSimulators = "com.loopkit.Loop.allowSimulators"
23-
case studyProductSelection = "com.loopkit.Loop.studyProductSelection"
23+
case studyProductSelection = "org.tidepool.plugins.TidepoolSupport.StudyProductSelection"
2424
case resetLoop = "com.loopkit.Loop.resetLoop"
2525
}
2626

0 commit comments

Comments
 (0)