Skip to content

Commit

Permalink
Hide temperature readings which are more outdated than 24 hours
Browse files Browse the repository at this point in the history
  • Loading branch information
user890104 committed Jan 10, 2024
1 parent 5c2201b commit 7dd91a4
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/widgets/SensorReading/SensorReading.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,16 @@ const SensorReading = ({
const formattedTimestamp = formatDefault(lastUpdate) + ' (' + formatDistanceToNow(lastUpdate) + ')';
const unit = units[type];
const formattedValue = value.toFixed(unit[1]) + unit[0];
const isCurrent = timestamp && Date.now() - timestamp <= 3_600_000;
const readingAge = Date.now() - timestamp;
const isCurrent = readingAge <= 3_600_000;
const isVisible = readingAge <= 86_400_000;
// TODO: only for type === Temperature
const thermometerState = thresholds.filter(threshold => threshold < value).length;

if (!isVisible) {
return null;
}

return (<Col>
<Card bg="primary" text={isCurrent ? 'white' : 'secondary'}>
<Card.Body>
Expand Down

0 comments on commit 7dd91a4

Please sign in to comment.