Hi there! Try this instead:
let discouragedDuration = await data.flatMap { $0.activitySegments }.flatMap { $0.categories }.flatMap { $0.applications }.reduce(0, {$0 + $1.totalActivityDuration})
Not sure why this approach actually takes the filter into account, but my guess is that the filter doesn't apply as high up as the activitySegments level. Hope this works for you; it did for me.
Post
Replies
Boosts
Views
Activity
var body: some Scene {
WindowGroup {
VStack{
ContentView()
}
.onAppear {
Task {
do {
try await center.requestAuthorization(for: .individual)
} catch {
print("Failed to enroll with error: \(error.localizedDescription)")
}
}
}
}
}
This is the authorization code I am using.