Skip to content

Commit

Permalink
used configure() to populate updated toggleMap
Browse files Browse the repository at this point in the history
  • Loading branch information
dhruvna1k committed Mar 5, 2024
1 parent e9e0aa3 commit 9a09ecd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
18 changes: 13 additions & 5 deletions Prisma/PrivacyControls/PrivacyModule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -68,18 +68,26 @@ public class PrivacyModule: Module, EnvironmentAccessible {

var dataCategoryItems: [DataCategoryItem] = []
var sampleTypeList: [HKSampleType]
var toggleMapUpdated: [String: Bool] = [:]

@StandardActor var standard: PrismaStandard


var configuration: Configuration {
Configuration(standard: PrismaStandard()) { }
}

Check warning on line 78 in Prisma/PrivacyControls/PrivacyModule.swift

View check run for this annotation

Codecov / codecov/patch

Prisma/PrivacyControls/PrivacyModule.swift#L76-L78

Added lines #L76 - L78 were not covered by tests

public required init(sampleTypeList: [HKSampleType]) {
self.sampleTypeList = sampleTypeList
self.dataCategoryItems = self.getDataCategoryItems()
}

var configuration: Configuration {
Configuration(standard: PrismaStandard()) { }
public func configure() {
Task {
toggleMapUpdated = await getHKSampleTypeMappings()
}
}

public func getDataCategoryItems() -> [DataCategoryItem] {
// make dictionary into alphabetically sorted array of key-value tuples
let sortedDataCategoryItems = identifierUIString.sorted { $0.key < $1.key }
Expand All @@ -95,13 +103,13 @@ public class PrivacyModule: Module, EnvironmentAccessible {
return dataCategoryItems
}

public func getHKSampleTypeMappings() async {
public func getHKSampleTypeMappings() async -> [String: Bool] {
var toggleMapUpdated: [String: Bool] = [:]

for sampleType in sampleTypeList {
let identifier = await standard.getSampleIdentifierFromHKSampleType(sampleType: sampleType)
toggleMapUpdated[identifier ?? "Unidentified Sample Type"] = true
}
return toggleMapUpdated
}

}
4 changes: 2 additions & 2 deletions Prisma/Standard/PrismaStandard+HealthKit.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ extension PrismaStandard {
return quantitySample.quantityType.identifier
case let categorySample as HKCategorySample:
return categorySample.categoryType.identifier
case let workout as HKWorkout:
// return "\(workout.workoutActivityType)"
case is HKWorkout:
// return "\lcal(workout.workoutActivityType)"
return "workout"
// Add more cases for other HKSample subclasses if needed
default:
Expand Down

0 comments on commit 9a09ecd

Please sign in to comment.