Skip to content

Commit

Permalink
Features/fixadd (#44)
Browse files Browse the repository at this point in the history
# *Fixing add function to make pull request

## ♻️ 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.


## ⚙️ 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.*


## 📚 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.*


## ✅ 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.*


## 📝 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).
  • Loading branch information
dhruvna1k authored Mar 14, 2024
1 parent 9c38895 commit f5d870e
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 31 deletions.
5 changes: 1 addition & 4 deletions Prisma/PrivacyControls/PrivacyModule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
28 changes: 3 additions & 25 deletions Prisma/Standard/PrismaStandard+HealthKit.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Prisma/Standard/PrismaStandard.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import SpeziOnboarding
import SpeziQuestionnaire
import SwiftUI


actor PrismaStandard: Standard, EnvironmentAccessible, HealthKitConstraint, OnboardingConstraint, AccountStorageConstraint {
enum PrismaStandardError: Error {
case userNotAuthenticatedYet
Expand All @@ -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

Expand Down
3 changes: 2 additions & 1 deletion firebase.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@
},
"singleProjectMode": true
}
}
}

0 comments on commit f5d870e

Please sign in to comment.