From f5d870e881624a24af398c5f74842c7471fafa6a Mon Sep 17 00:00:00 2001 From: Dhruv Naik <125706142+dhruvna1k@users.noreply.github.com> Date: Wed, 13 Mar 2024 20:56:33 -0700 Subject: [PATCH] Features/fixadd (#44) # *Fixing add function to make pull request ## :recycle: Current situation & Problem I was using an @Dependency incorrectly and needed to use it within the add function of the Prisma Standard allow the program to run properly and the toggle states can be accessed within the Standard now for omitting data writing to Firestore. ## :gear: Release Notes *Add a bullet point list summary of the feature and possible migration guides if this is a breaking change so this section can be added to the release notes.* *Include code snippets that provide examples of the feature implemented or links to the documentation if it appends or changes the public interface.* ## :books: Documentation *Please ensure that you properly document any additions in conformance to [Spezi Documentation Guide](https://github.com/StanfordSpezi/.github/blob/main/DOCUMENTATIONGUIDE.md).* *You can use this section to describe your solution, but we encourage contributors to document your reasoning and changes using in-line documentation.* ## :white_check_mark: Testing *Please ensure that the PR meets the testing requirements set by CodeCov and that new functionality is appropriately tested.* *This section describes important information about the tests and why some elements might not be testable.* ## :pencil: Code of Conduct & Contributing Guidelines By submitting creating this pull request, you agree to follow our [Code of Conduct](https://github.com/CS342/.github/blob/main/CODE_OF_CONDUCT.md) and [Contributing Guidelines](https://github.com/CS342/.github/blob/main/CONTRIBUTING.md): - [x] I agree to follow the [Code of Conduct](https://github.com/CS342/.github/blob/main/CODE_OF_CONDUCT.md) and [Contributing Guidelines](https://github.com/CS342/.github/blob/main/CONTRIBUTING.md). --- Prisma/PrivacyControls/PrivacyModule.swift | 5 +--- .../Standard/PrismaStandard+HealthKit.swift | 28 ++----------------- Prisma/Standard/PrismaStandard.swift | 2 +- firebase.json | 3 +- 4 files changed, 7 insertions(+), 31 deletions(-) diff --git a/Prisma/PrivacyControls/PrivacyModule.swift b/Prisma/PrivacyControls/PrivacyModule.swift index b179af0..f9c38b9 100644 --- a/Prisma/PrivacyControls/PrivacyModule.swift +++ b/Prisma/PrivacyControls/PrivacyModule.swift @@ -177,12 +177,9 @@ public class PrivacyModule: Module, EnvironmentAccessible, ObservableObject { ) ] - var configuration: Configuration { - Configuration(standard: PrismaStandard()) { } - } - public required init(sampleTypeList: [HKSampleType]) { self.sampleTypeList = sampleTypeList + var sampleTypeIdentifiers: [String] = [] for sampleType in sampleTypeList { if sampleType == HKWorkoutType.workoutType() { diff --git a/Prisma/Standard/PrismaStandard+HealthKit.swift b/Prisma/Standard/PrismaStandard+HealthKit.swift index e276f3c..20ea16b 100644 --- a/Prisma/Standard/PrismaStandard+HealthKit.swift +++ b/Prisma/Standard/PrismaStandard+HealthKit.swift @@ -90,31 +90,9 @@ extension PrismaStandard { /// Adds a new `HKSample` to the Firestore. /// - Parameter response: The `HKSample` that should be added. func add(sample: HKSample) async { - let sampleList = [ - // Activity - HKQuantityType(.stepCount), - HKQuantityType(.distanceWalkingRunning), - HKQuantityType(.basalEnergyBurned), - HKQuantityType(.activeEnergyBurned), - HKQuantityType(.flightsClimbed), - HKQuantityType(.appleExerciseTime), - HKQuantityType(.appleMoveTime), - HKQuantityType(.appleStandTime), - - // Vital Signs - HKQuantityType(.heartRate), - HKQuantityType(.restingHeartRate), - HKQuantityType(.heartRateVariabilitySDNN), - HKQuantityType(.walkingHeartRateAverage), - HKQuantityType(.oxygenSaturation), - HKQuantityType(.respiratoryRate), - HKQuantityType(.bodyTemperature), - - // Other events - HKCategoryType(.sleepAnalysis), - HKWorkoutType.workoutType() - ] - let privacyModule = PrivacyModule(sampleTypeList: sampleList) + guard let privacyModule = privacyModule else { + return + } let toggleMap = await privacyModule.getHKSampleTypeMappings() let identifier: String diff --git a/Prisma/Standard/PrismaStandard.swift b/Prisma/Standard/PrismaStandard.swift index c11f05f..3939b1c 100644 --- a/Prisma/Standard/PrismaStandard.swift +++ b/Prisma/Standard/PrismaStandard.swift @@ -23,7 +23,6 @@ import SpeziOnboarding import SpeziQuestionnaire import SwiftUI - actor PrismaStandard: Standard, EnvironmentAccessible, HealthKitConstraint, OnboardingConstraint, AccountStorageConstraint { enum PrismaStandardError: Error { case userNotAuthenticatedYet @@ -38,6 +37,7 @@ actor PrismaStandard: Standard, EnvironmentAccessible, HealthKitConstraint, Onbo @Dependency var mockWebService: MockWebService? @Dependency var accountStorage: FirestoreAccountStorage? + @Dependency var privacyModule: PrivacyModule? @AccountReference var account: Account diff --git a/firebase.json b/firebase.json index 0b85064..fa427dc 100644 --- a/firebase.json +++ b/firebase.json @@ -21,4 +21,5 @@ }, "singleProjectMode": true } -} \ No newline at end of file +} +