Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#49 # Fix vitals graphs not updating on change of date resolution ## ♻️ Current situation & Problem Currently, we are seeing a bug where the vitals graphs do not update correctly when we change the date resolution (see issue #49). ## ⚙️ Release Notes - The problem was that a helper function in VitalsGraph.ViewModel (getInterval) that is called to group measurements by date as part of the aggregating process used self.dateUnit instead of a passed parameter unit: Before: ```swift private func getInterval(date: Date, unit: Calendar.Component) -> DateInterval? { calendar.dateInterval(of: dateUnit, for: date) } ``` After: ```swift private func getInterval(date: Date, unit: Calendar.Component) -> DateInterval? { calendar.dateInterval(of: unit, for: date) } ``` This caused the data to be aggregated according to the ViewModel's stored parameter dateUnit, which is only updated after the data has been processed with the new, passed parameter. Additional Changes: - Now use .task instead of .onAppear to process data in HKSampleGraph and VitalsGraph to reduce unnecessary data processing. - Removed the .onChange(of: data) modifier in VitalsGraph to reduce unnecessary data processing ## 📚 Documentation NA ## ✅ Testing Unit tests and UI tests still target the graphs, and user testing will cover the more nuanced interactions such as gestures to interact with the graphs. ### Code of Conduct & Contributing Guidelines By submitting creating this pull request, you agree to follow our [Code of Conduct](https://github.com/StanfordBDHG/.github/blob/main/CODE_OF_CONDUCT.md) and [Contributing Guidelines](https://github.com/StanfordBDHG/.github/blob/main/CONTRIBUTING.md): - [X] I agree to follow the [Code of Conduct](https://github.com/StanfordBDHG/.github/blob/main/CODE_OF_CONDUCT.md) and [Contributing Guidelines](https://github.com/StanfordBDHG/.github/blob/main/CONTRIBUTING.md).
- Loading branch information