Skip to content

Commit

Permalink
fix: hostd navigation bug
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfreska committed Jan 16, 2024
1 parent fa19535 commit 0aaec35
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/funny-lions-deliver.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'hostd': minor
---

Fixed an issue where the app would not navigate when the metrics data interval was set to ALL.
9 changes: 8 additions & 1 deletion apps/hostd/contexts/metrics/useNowAtInterval.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
import { useEffect, useState } from 'react'
import { DataInterval, getDataIntervalInMs } from './types'
import { hoursInMilliseconds } from '@siafoundation/design-system'

// now timestamp updated every interval
// used to reset the time range and keep the graph up to date
export function useNowAtInterval(dataInterval: DataInterval) {
const [now, setNow] = useState(new Date().getTime())
useEffect(() => {
setNow(new Date().getTime())
// set a minimum refresh rate of every 1 hour
const minIntervalMs = hoursInMilliseconds(1)
const intervalMs = Math.min(
getDataIntervalInMs(dataInterval),
minIntervalMs
)
const i = setInterval(() => {
setNow(new Date().getTime())
}, getDataIntervalInMs(dataInterval))
}, intervalMs)
return () => clearInterval(i)
}, [dataInterval])

Expand Down
1 change: 0 additions & 1 deletion libs/design-system/src/components/ChartXY/ChartXYGraph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,6 @@ export function ChartXYGraph<Key extends string, Cat extends string>({
// values don't make sense in stream graph
// tickFormat={stackOffset === 'wiggle' ? () => '' : undefined}
tickFormat={config.formatTickY}
tickTransform={`translate(-300px, 0)`}
tickLabelProps={(p) => ({
...p,
fill: theme.labels.color,
Expand Down

0 comments on commit 0aaec35

Please sign in to comment.