refactor(health): remove HRV field and improve notification types
- Remove heart rate variability (hrv) field from health data interfaces and implementations - Update default member name to Chinese localization - Replace type assertions with proper enum types in notification schedulers
This commit is contained in:
@@ -229,7 +229,6 @@ export default function ExploreScreen() {
|
|||||||
date: dateString,
|
date: dateString,
|
||||||
data: {
|
data: {
|
||||||
activeCalories: data.activeEnergyBurned,
|
activeCalories: data.activeEnergyBurned,
|
||||||
hrv: data.hrv,
|
|
||||||
heartRate: data.heartRate,
|
heartRate: data.heartRate,
|
||||||
activeEnergyBurned: data.activeEnergyBurned,
|
activeEnergyBurned: data.activeEnergyBurned,
|
||||||
activeCaloriesGoal: data.activeCaloriesGoal,
|
activeCaloriesGoal: data.activeCaloriesGoal,
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ export interface FitnessRingsData {
|
|||||||
|
|
||||||
export interface HealthData {
|
export interface HealthData {
|
||||||
activeCalories: number | null;
|
activeCalories: number | null;
|
||||||
hrv: number | null;
|
|
||||||
heartRate: number | null;
|
heartRate: number | null;
|
||||||
activeEnergyBurned: number;
|
activeEnergyBurned: number;
|
||||||
activeCaloriesGoal: number;
|
activeCaloriesGoal: number;
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ export type UserState = {
|
|||||||
activityHistory: ActivityHistoryItem[];
|
activityHistory: ActivityHistoryItem[];
|
||||||
};
|
};
|
||||||
|
|
||||||
export const DEFAULT_MEMBER_NAME = '';
|
export const DEFAULT_MEMBER_NAME = '朋友';
|
||||||
|
|
||||||
const getInitialState = (): UserState => {
|
const getInitialState = (): UserState => {
|
||||||
const preloaded = getPreloadedUserData();
|
const preloaded = getPreloadedUserData();
|
||||||
|
|||||||
@@ -207,7 +207,6 @@ export type HourlyStandData = {
|
|||||||
|
|
||||||
export type TodayHealthData = {
|
export type TodayHealthData = {
|
||||||
activeEnergyBurned: number; // kilocalories
|
activeEnergyBurned: number; // kilocalories
|
||||||
hrv: number | null; // 心率变异性 (ms)
|
|
||||||
// 健身圆环数据
|
// 健身圆环数据
|
||||||
activeCalories: number;
|
activeCalories: number;
|
||||||
activeCaloriesGoal: number;
|
activeCaloriesGoal: number;
|
||||||
@@ -607,7 +606,6 @@ export async function fetchMaximumHeartRate(_options: HealthDataOptions): Promis
|
|||||||
function getDefaultHealthData(): TodayHealthData {
|
function getDefaultHealthData(): TodayHealthData {
|
||||||
return {
|
return {
|
||||||
activeEnergyBurned: 0,
|
activeEnergyBurned: 0,
|
||||||
hrv: null,
|
|
||||||
activeCalories: 0,
|
activeCalories: 0,
|
||||||
activeCaloriesGoal: 350,
|
activeCaloriesGoal: 350,
|
||||||
exerciseMinutes: 0,
|
exerciseMinutes: 0,
|
||||||
@@ -628,19 +626,16 @@ export async function fetchHealthDataForDate(date: Date): Promise<TodayHealthDat
|
|||||||
// 并行获取所有健康数据
|
// 并行获取所有健康数据
|
||||||
const [
|
const [
|
||||||
activeEnergyBurned,
|
activeEnergyBurned,
|
||||||
hrv,
|
|
||||||
activitySummary,
|
activitySummary,
|
||||||
heartRate
|
heartRate
|
||||||
] = await Promise.all([
|
] = await Promise.all([
|
||||||
fetchActiveEnergyBurned(options),
|
fetchActiveEnergyBurned(options),
|
||||||
fetchHeartRateVariability(options),
|
|
||||||
fetchActivitySummary(options),
|
fetchActivitySummary(options),
|
||||||
fetchHeartRate(options)
|
fetchHeartRate(options)
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
activeEnergyBurned,
|
activeEnergyBurned,
|
||||||
hrv,
|
|
||||||
activeCalories: Math.round(activitySummary?.activeEnergyBurned || 0),
|
activeCalories: Math.round(activitySummary?.activeEnergyBurned || 0),
|
||||||
activeCaloriesGoal: Math.round(activitySummary?.activeEnergyBurnedGoal || 350),
|
activeCaloriesGoal: Math.round(activitySummary?.activeEnergyBurnedGoal || 350),
|
||||||
exerciseMinutes: Math.round(activitySummary?.appleExerciseTime || 0),
|
exerciseMinutes: Math.round(activitySummary?.appleExerciseTime || 0),
|
||||||
|
|||||||
@@ -803,7 +803,7 @@ export class WaterNotificationHelpers {
|
|||||||
priority: 'normal',
|
priority: 'normal',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'DAILY' as any,
|
type: Notifications.SchedulableTriggerInputTypes.DAILY,
|
||||||
hour: hour,
|
hour: hour,
|
||||||
minute: 0,
|
minute: 0,
|
||||||
}
|
}
|
||||||
@@ -1278,7 +1278,7 @@ export class DailySummaryNotificationHelpers {
|
|||||||
priority: 'normal',
|
priority: 'normal',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'DAILY' as any,
|
type: Notifications.SchedulableTriggerInputTypes.DAILY,
|
||||||
hour: hour,
|
hour: hour,
|
||||||
minute: minute,
|
minute: minute,
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user