Skip to content

Commit 9623b16

Browse files
authored
Merge pull request #334 from sh940701/feat/serialize-workout-event-metadata
feat: serialize HKWorkoutEvent.metadata in workout queries
2 parents 9fe1cb7 + 9cfdac9 commit 9623b16

3 files changed

Lines changed: 11 additions & 3 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@kingstinct/react-native-healthkit": minor
3+
---
4+
5+
Serialize HKWorkoutEvent.metadata in workout query results, exposing per-event metadata such as HKSwimmingStrokeStyle on swimming lap events.

packages/react-native-healthkit/ios/WorkoutProxy.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,8 @@ class WorkoutProxy: HybridWorkoutProxySpec {
498498
return WorkoutEvent(
499499
type: type,
500500
startDate: event.dateInterval.start,
501-
endDate: event.dateInterval.end
501+
endDate: event.dateInterval.end,
502+
metadata: serializeMetadata(event.metadata)
502503
)
503504
}
504505
warnWithPrefix(
@@ -554,4 +555,4 @@ class WorkoutProxy: HybridWorkoutProxySpec {
554555
return try await getSerializedWorkoutLocations(workout: self.workout)
555556
}
556557
}
557-
}
558+
}

packages/react-native-healthkit/src/types/Workouts.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { AnyMap } from 'react-native-nitro-modules'
12
import type { WorkoutProxy } from '../specs/WorkoutProxy.nitro'
23
import type { BaseSample, ComparisonPredicateOperator } from '../types'
34
import type { Quantity } from './QuantityType'
@@ -95,6 +96,7 @@ export interface WorkoutEvent {
9596
readonly type: WorkoutEventType
9697
readonly startDate: Date
9798
readonly endDate: Date
99+
readonly metadata?: AnyMap
98100
}
99101

100102
export enum WorkoutEventType {
@@ -212,4 +214,4 @@ export interface WorkoutSample extends BaseSample {
212214
readonly metadataIndoorWorkout?: boolean
213215
readonly metadataAverageSpeed?: Quantity
214216
readonly metadataMaximumSpeed?: Quantity
215-
}
217+
}

0 commit comments

Comments
 (0)