Skip to content

Commit

Permalink
fix: default dataset refresh interval
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfreska committed Feb 15, 2024
1 parent cdf540c commit 7c8e52b
Show file tree
Hide file tree
Showing 21 changed files with 94 additions and 28 deletions.
5 changes: 5 additions & 0 deletions .changeset/new-suns-rush.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'hostd': minor
---

Integrity check alert sector data will now update when there is an ongoing integrity check.
7 changes: 7 additions & 0 deletions .changeset/tough-llamas-do.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'hostd': minor
'renterd': minor
'walletd': minor
---

All app data will now refresh more frequently.
3 changes: 3 additions & 0 deletions apps/hostd/config/swr.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { secondsInMilliseconds } from '@siafoundation/design-system'

export const defaultDatasetRefreshInterval = secondsInMilliseconds(15)
4 changes: 2 additions & 2 deletions apps/hostd/contexts/contracts/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {
useDatasetEmptyState,
useServerFilters,
getContractsTimeRangeBlockHeight,
secondsInMilliseconds,
} from '@siafoundation/design-system'
import { useRouter } from 'next/router'
import {
Expand All @@ -22,6 +21,7 @@ import { columns } from './columns'
import { useDataset } from './dataset'
import { useSyncStatus } from '../../hooks/useSyncStatus'
import { useSiascanUrl } from '../../hooks/useSiascanUrl'
import { defaultDatasetRefreshInterval } from '../../config/swr'

const defaultLimit = 50

Expand Down Expand Up @@ -67,7 +67,7 @@ function useContractsMain() {
},
config: {
swr: {
refreshInterval: secondsInMilliseconds(60),
refreshInterval: defaultDatasetRefreshInterval,
},
},
})
Expand Down
4 changes: 2 additions & 2 deletions apps/hostd/contexts/metrics/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
formatChartData,
getDataIntervalLabelFormatter,
getTimeRange,
minutesInMilliseconds,
secondsInMilliseconds,
ValueScFiat,
} from '@siafoundation/design-system'
import {
Expand Down Expand Up @@ -114,7 +114,7 @@ function useMetricsMain() {
config: {
swr: {
revalidateOnFocus: false,
refreshInterval: minutesInMilliseconds(5),
refreshInterval: secondsInMilliseconds(60),
},
},
})
Expand Down
6 changes: 3 additions & 3 deletions apps/hostd/contexts/transactions/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {
TxType,
daysInMilliseconds,
getTransactionType,
secondsInMilliseconds,
useDatasetEmptyState,
} from '@siafoundation/design-system'
import {
Expand All @@ -16,6 +15,7 @@ import BigNumber from 'bignumber.js'
import { useRouter } from 'next/router'
import { useSiascanUrl } from '../../hooks/useSiascanUrl'
import { Transaction } from '@siafoundation/types'
import { defaultDatasetRefreshInterval } from '../../config/swr'

const defaultLimit = 50
const filters = []
Expand Down Expand Up @@ -46,14 +46,14 @@ function useTransactionsMain() {
},
config: {
swr: {
refreshInterval: secondsInMilliseconds(60),
refreshInterval: defaultDatasetRefreshInterval,
},
},
})
const pending = useWalletPending({
config: {
swr: {
refreshInterval: secondsInMilliseconds(60),
refreshInterval: defaultDatasetRefreshInterval,
},
},
})
Expand Down
3 changes: 2 additions & 1 deletion apps/hostd/contexts/volumes/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { createContext, useContext, useMemo } from 'react'
import { columnsDefaultVisible, TableColumnId } from './types'
import { columns } from './columns'
import { useDataset } from './dataset'
import { defaultDatasetRefreshInterval } from '../../config/swr'

function useVolumesMain() {
const {
Expand All @@ -36,7 +37,7 @@ function useVolumesMain() {
refreshInterval: (data) =>
data?.find((v) => isOperationInProgress(v))
? secondsInMilliseconds(5)
: secondsInMilliseconds(60),
: defaultDatasetRefreshInterval,
},
},
})
Expand Down
11 changes: 10 additions & 1 deletion apps/hostd/dialogs/AlertsDialog.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
AlertsDialog as DSAlertsDialog,
secondsInMilliseconds,
Text,
triggerErrorToast,
triggerSuccessToast,
Expand All @@ -19,7 +20,15 @@ type Props = {
}

export function AlertsDialog({ open, onOpenChange }: Props) {
const alerts = useAlerts()
const alerts = useAlerts({
config: {
swr: {
refreshInterval: open
? secondsInMilliseconds(20)
: secondsInMilliseconds(60),
},
},
})
const dismiss = useAlertsDismiss()

const dismissOne = useCallback(
Expand Down
3 changes: 3 additions & 0 deletions apps/renterd/config/swr.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { secondsInMilliseconds } from '@siafoundation/design-system'

export const defaultDatasetRefreshInterval = secondsInMilliseconds(15)
4 changes: 2 additions & 2 deletions apps/renterd/contexts/contracts/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import {
useDatasetEmptyState,
useClientFilters,
useClientFilteredDataset,
minutesInMilliseconds,
daysInMilliseconds,
secondsInMilliseconds,
} from '@siafoundation/design-system'
import { useRouter } from 'next/router'
import {
Expand Down Expand Up @@ -48,7 +48,7 @@ function useContractsMain() {
const response = useContractsData({
config: {
swr: {
refreshInterval: minutesInMilliseconds(1),
refreshInterval: secondsInMilliseconds(15),
},
},
})
Expand Down
4 changes: 2 additions & 2 deletions apps/renterd/contexts/filesDirectory/dataset.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import {
} from '@siafoundation/react-renterd'
import { useDataset as useDatasetGeneric } from '../filesManager/dataset'
import { bucketAndKeyParamsFromPath } from '../../lib/paths'
import { minutesInMilliseconds } from '@siafoundation/design-system'
import { useRouter } from 'next/router'
import { useMemo } from 'react'
import { useFilesManager } from '../filesManager'
import { defaultDatasetRefreshInterval } from '../../config/swr'

const defaultLimit = 50

Expand Down Expand Up @@ -49,7 +49,7 @@ export function useDataset() {
params,
config: {
swr: {
refreshInterval: minutesInMilliseconds(1),
refreshInterval: defaultDatasetRefreshInterval,
},
},
})
Expand Down
8 changes: 3 additions & 5 deletions apps/renterd/contexts/filesFlat/dataset.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import { ObjectListParams, useObjectList } from '@siafoundation/react-renterd'
import { SortField } from '../filesManager/types'
import { useDataset as useDatasetGeneric } from '../filesManager/dataset'
import {
ServerFilterItem,
minutesInMilliseconds,
} from '@siafoundation/design-system'
import { ServerFilterItem } from '@siafoundation/design-system'
import { useRouter } from 'next/router'
import { useMemo } from 'react'
import { useFilesManager } from '../filesManager'
import { defaultDatasetRefreshInterval } from '../../config/swr'

type Props = {
setActiveDirectory: (func: (directory: string[]) => string[]) => void
Expand Down Expand Up @@ -51,7 +49,7 @@ export function useDataset({ sortDirection, sortField, filters }: Props) {
payload: params,
config: {
swr: {
refreshInterval: minutesInMilliseconds(1),
refreshInterval: defaultDatasetRefreshInterval,
},
},
})
Expand Down
6 changes: 3 additions & 3 deletions apps/renterd/contexts/hosts/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
useServerFilters,
triggerErrorToast,
truncate,
minutesInMilliseconds,
} from '@siafoundation/design-system'
import {
HostsSearchFilterMode,
Expand Down Expand Up @@ -38,6 +37,7 @@ import { useAppSettings } from '@siafoundation/react-core'
import { Commands, emptyCommands } from '../../components/Hosts/HostMap/Globe'
import { useSiaCentralHosts } from '@siafoundation/react-sia-central'
import { useSiascanUrl } from '../../hooks/useSiascanUrl'
import { defaultDatasetRefreshInterval } from '../../config/swr'

const defaultLimit = 50

Expand Down Expand Up @@ -83,7 +83,7 @@ function useHostsMain() {
swr: {
// before autopilot is configured this will repeatedly 500
errorRetryInterval: 20_000,
refreshInterval: minutesInMilliseconds(1),
refreshInterval: defaultDatasetRefreshInterval,
},
},
})
Expand All @@ -103,7 +103,7 @@ function useHostsMain() {
},
config: {
swr: {
refreshInterval: minutesInMilliseconds(1),
refreshInterval: defaultDatasetRefreshInterval,
},
},
})
Expand Down
4 changes: 2 additions & 2 deletions apps/renterd/contexts/keys/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {
useDatasetEmptyState,
useClientFilters,
useClientFilteredDataset,
minutesInMilliseconds,
} from '@siafoundation/design-system'
import { useRouter } from 'next/router'
import { createContext, useContext, useMemo } from 'react'
Expand All @@ -15,6 +14,7 @@ import {
} from './types'
import { columns } from './columns'
import { useS3AuthenticationSettings } from '../../hooks/useS3AuthenticationSettings'
import { defaultDatasetRefreshInterval } from '../../config/swr'

const defaultLimit = 50

Expand All @@ -25,7 +25,7 @@ function useKeysMain() {
const response = useS3AuthenticationSettings({
config: {
swr: {
refreshInterval: minutesInMilliseconds(1),
refreshInterval: defaultDatasetRefreshInterval,
},
},
})
Expand Down
6 changes: 3 additions & 3 deletions apps/renterd/contexts/transactions/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {
TxType,
daysInMilliseconds,
getTransactionType,
secondsInMilliseconds,
stripPrefix,
useDatasetEmptyState,
} from '@siafoundation/design-system'
Expand All @@ -17,6 +16,7 @@ import BigNumber from 'bignumber.js'
import { useRouter } from 'next/router'
import { useSiascanUrl } from '../../hooks/useSiascanUrl'
import { Transaction } from '@siafoundation/types'
import { defaultDatasetRefreshInterval } from '../../config/swr'

const defaultLimit = 50
const filters = []
Expand Down Expand Up @@ -54,15 +54,15 @@ function useTransactionsMain() {
},
config: {
swr: {
refreshInterval: secondsInMilliseconds(60),
refreshInterval: defaultDatasetRefreshInterval,
},
},
})

const pending = useWalletPending({
config: {
swr: {
refreshInterval: secondsInMilliseconds(60),
refreshInterval: defaultDatasetRefreshInterval,
},
},
})
Expand Down
9 changes: 8 additions & 1 deletion apps/renterd/dialogs/AlertsDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,21 @@ import { HostContextMenu } from '../components/Hosts/HostContextMenu'
import { useDialog } from '../contexts/dialog'
import { useFilesManager } from '../contexts/filesManager'
import { getDirectorySegmentsFromPath } from '../lib/paths'
import { defaultDatasetRefreshInterval } from '../config/swr'

type Props = {
open: boolean
onOpenChange: (val: boolean) => void
}

export function AlertsDialog({ open, onOpenChange }: Props) {
const alerts = useAlerts()
const alerts = useAlerts({
config: {
swr: {
refreshInterval: defaultDatasetRefreshInterval,
},
},
})
const dismiss = useAlertsDismiss()

const dismissOne = useCallback(
Expand Down
3 changes: 3 additions & 0 deletions apps/walletd/config/swr.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { secondsInMilliseconds } from '@siafoundation/design-system'

export const defaultDatasetRefreshInterval = secondsInMilliseconds(15)
6 changes: 6 additions & 0 deletions apps/walletd/contexts/addresses/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { columns } from './columns'
import { useRouter } from 'next/router'
import { useDialog } from '../dialog'
import { useSiascanUrl } from '../../hooks/useSiascanUrl'
import { defaultDatasetRefreshInterval } from '../../config/swr'

export function useAddressesMain() {
const { openDialog } = useDialog()
Expand All @@ -28,6 +29,11 @@ export function useAddressesMain() {
params: {
id: walletId,
},
config: {
swr: {
refreshInterval: defaultDatasetRefreshInterval,
},
},
})

const dataset = useMemo<AddressData[] | null>(() => {
Expand Down
11 changes: 11 additions & 0 deletions apps/walletd/contexts/events/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { columns } from './columns'
import { useRouter } from 'next/router'
import BigNumber from 'bignumber.js'
import { useSiascanUrl } from '../../hooks/useSiascanUrl'
import { defaultDatasetRefreshInterval } from '../../config/swr'

const defaultLimit = 100

Expand All @@ -41,6 +42,11 @@ export function useEventsMain() {
params: {
id,
},
config: {
swr: {
refreshInterval: defaultDatasetRefreshInterval,
},
},
})
const responseEvents = useWalletEvents({
disabled: !id,
Expand All @@ -49,6 +55,11 @@ export function useEventsMain() {
offset,
id,
},
config: {
swr: {
refreshInterval: defaultDatasetRefreshInterval,
},
},
})

const walletSub = useWalletSubscribe()
Expand Down
9 changes: 8 additions & 1 deletion apps/walletd/contexts/wallets/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,16 @@ import { routes } from '../../config/routes'
import { useWalletSeedCache } from './useWalletSeedCache'
import { useDialog } from '../dialog'
import { useAppSettings } from '@siafoundation/react-core'
import { defaultDatasetRefreshInterval } from '../../config/swr'

function useWalletsMain() {
const response = useWalletsData()
const response = useWalletsData({
config: {
swr: {
refreshInterval: defaultDatasetRefreshInterval,
},
},
})
const router = useRouter()
const { openDialog } = useDialog()
const { setOnLockCallback } = useAppSettings()
Expand Down
Loading

0 comments on commit 7c8e52b

Please sign in to comment.