matinzd / react-native-health-connect

React native library for health connect (Android only)
http://matinzd.github.io/react-native-health-connect
MIT License
231 stars 43 forks source link

chore: renames/refactors record utils and record interface #143

Closed ugurakin1 closed 3 weeks ago

ugurakin1 commented 2 months ago

Summary

I'm currently tackling adding permission support for ExerciseRoutes. The way we couple permissions with records currently makes this a bit difficult as ExerciseRoutes aren't exactly records but do require permissions. I propose we use this opportunity to decouple permissions and record types a bit further.

As a first step, I would like to refactor ReactHealthRecord as an abstract utils class as it only contains static methods and rename the base interface to ReactHealthRecord (I believe it was named differently due to name clashes before).

Further changes will probably include creating enums for supported React record types and React permission types that can be used to bridge react input/outputs in a more structural manor.

UDPATE:Probably a better way might be to configure Exercise permissions to include an optional parameter? There are no direct ways to read exercise route records without reading exercises so might be better to keep record based model. Either way, this PR might be a slight improvement so feel free to review.

UPDATE 2: Okay requesting route permissions actually work very differently to all the other permissions. Depending on what the apps use these permissions for it might be best to either redirect to permission screen or request per exercise (we would need to expose a method for this).

I'm dropping work for this as forwarding users to health connect settings seem much simpler for managing permissions.

Testing

Went through the example app and verified all the existing functionality is in tact.