@@ -2,6 +2,7 @@ import React, { useState, useContext, useRef, useMemo } from "react";
22import styles from "./BatteriesModule.module.scss" ;
33import { useGlobalTicker , useMeasurementsStore , usePodDataStore } from "common" ;
44import { LostConnectionContext } from "services/connections" ;
5+ import { DELTA_SAMPLE_PERIOD , DELTA_GRACE_PERIOD } from "constants/deltaTracking" ;
56
67interface CellProps {
78 value : number | null ;
@@ -50,14 +51,14 @@ const BatteriesModule: React.FC<{ id: string | number }> = ({ id }) => {
5051 const now = Date . now ( ) ;
5152 const prevData = deltaTrackingRef . current [ key ] ;
5253
53- // Check if 400ms have passed since last sample
54- if ( prevData && now - prevData . lastSampleTime < 400 ) {
54+ // Check if sample period has passed since last sample
55+ if ( prevData && now - prevData . lastSampleTime < DELTA_SAMPLE_PERIOD ) {
5556 // Not enough time passed, return current value if not stale, otherwise null
5657 const currentValue = originalGetter ( ) ;
5758 return prevData . isStale ? null : currentValue ;
5859 }
5960
60- // 400ms have passed or no previous data, get fresh value
61+ // Sample period has passed or no previous data, get fresh value
6162 const currentValue = originalGetter ( ) ;
6263
6364 // Initialize if no previous data
@@ -90,7 +91,7 @@ const BatteriesModule: React.FC<{ id: string | number }> = ({ id }) => {
9091 } else {
9192 // Value hasn't changed significantly, check if it's been stale for too long
9293 const staleDuration = now - prevData . lastChangeTime ;
93- const isStale = staleDuration > 100 ; // 100ms grace period
94+ const isStale = staleDuration > DELTA_GRACE_PERIOD ; // Grace period
9495
9596 deltaTrackingRef . current [ key ] = {
9697 value : currentValue ,
0 commit comments