From 4506593d4f869cae547169f841d69e28ebc49c5d Mon Sep 17 00:00:00 2001 From: Alex Freska Date: Wed, 14 Feb 2024 15:29:47 -0500 Subject: [PATCH] fix: default dataset refresh interval --- .changeset/new-suns-rush.md | 5 +++++ .changeset/tough-llamas-do.md | 7 +++++++ apps/hostd/config/swr.ts | 3 +++ apps/hostd/contexts/contracts/index.tsx | 4 ++-- apps/hostd/contexts/metrics/index.tsx | 4 ++-- apps/hostd/contexts/transactions/index.tsx | 6 +++--- apps/hostd/contexts/volumes/index.tsx | 3 ++- apps/hostd/dialogs/AlertsDialog.tsx | 9 ++++++++- apps/renterd/config/swr.ts | 3 +++ apps/renterd/contexts/contracts/index.tsx | 4 ++-- apps/renterd/contexts/filesDirectory/dataset.tsx | 4 ++-- apps/renterd/contexts/filesFlat/dataset.tsx | 8 +++----- apps/renterd/contexts/hosts/index.tsx | 6 +++--- apps/renterd/contexts/keys/index.tsx | 4 ++-- apps/renterd/contexts/transactions/index.tsx | 6 +++--- apps/renterd/dialogs/AlertsDialog.tsx | 9 ++++++++- apps/walletd/config/swr.ts | 3 +++ apps/walletd/contexts/addresses/index.tsx | 6 ++++++ apps/walletd/contexts/events/index.tsx | 11 +++++++++++ apps/walletd/contexts/wallets/index.tsx | 9 ++++++++- apps/walletd/hooks/useWalletAddresses.tsx | 6 ++++++ 21 files changed, 92 insertions(+), 28 deletions(-) create mode 100644 .changeset/new-suns-rush.md create mode 100644 .changeset/tough-llamas-do.md create mode 100644 apps/hostd/config/swr.ts create mode 100644 apps/renterd/config/swr.ts create mode 100644 apps/walletd/config/swr.ts diff --git a/.changeset/new-suns-rush.md b/.changeset/new-suns-rush.md new file mode 100644 index 000000000..4e12ed903 --- /dev/null +++ b/.changeset/new-suns-rush.md @@ -0,0 +1,5 @@ +--- +'hostd': minor +--- + +Integrity check alert sector data will now update when there is an ongoing integrity check. diff --git a/.changeset/tough-llamas-do.md b/.changeset/tough-llamas-do.md new file mode 100644 index 000000000..a32a75385 --- /dev/null +++ b/.changeset/tough-llamas-do.md @@ -0,0 +1,7 @@ +--- +'hostd': minor +'renterd': minor +'walletd': minor +--- + +All app data will now refresh more frequently. diff --git a/apps/hostd/config/swr.ts b/apps/hostd/config/swr.ts new file mode 100644 index 000000000..23d7e1297 --- /dev/null +++ b/apps/hostd/config/swr.ts @@ -0,0 +1,3 @@ +import { secondsInMilliseconds } from '@siafoundation/design-system' + +export const defaultDatasetRefreshInterval = secondsInMilliseconds(15) diff --git a/apps/hostd/contexts/contracts/index.tsx b/apps/hostd/contexts/contracts/index.tsx index 1746afca5..996506a3a 100644 --- a/apps/hostd/contexts/contracts/index.tsx +++ b/apps/hostd/contexts/contracts/index.tsx @@ -3,7 +3,6 @@ import { useDatasetEmptyState, useServerFilters, getContractsTimeRangeBlockHeight, - secondsInMilliseconds, } from '@siafoundation/design-system' import { useRouter } from 'next/router' import { @@ -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 @@ -67,7 +67,7 @@ function useContractsMain() { }, config: { swr: { - refreshInterval: secondsInMilliseconds(60), + refreshInterval: defaultDatasetRefreshInterval, }, }, }) diff --git a/apps/hostd/contexts/metrics/index.tsx b/apps/hostd/contexts/metrics/index.tsx index 79a4db03c..5f1424e0f 100644 --- a/apps/hostd/contexts/metrics/index.tsx +++ b/apps/hostd/contexts/metrics/index.tsx @@ -5,7 +5,7 @@ import { formatChartData, getDataIntervalLabelFormatter, getTimeRange, - minutesInMilliseconds, + secondsInMilliseconds, ValueScFiat, } from '@siafoundation/design-system' import { @@ -114,7 +114,7 @@ function useMetricsMain() { config: { swr: { revalidateOnFocus: false, - refreshInterval: minutesInMilliseconds(5), + refreshInterval: secondsInMilliseconds(60), }, }, }) diff --git a/apps/hostd/contexts/transactions/index.tsx b/apps/hostd/contexts/transactions/index.tsx index d08b19995..f19a8d8a0 100644 --- a/apps/hostd/contexts/transactions/index.tsx +++ b/apps/hostd/contexts/transactions/index.tsx @@ -2,7 +2,6 @@ import { TxType, daysInMilliseconds, getTransactionType, - secondsInMilliseconds, useDatasetEmptyState, } from '@siafoundation/design-system' import { @@ -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 = [] @@ -46,14 +46,14 @@ function useTransactionsMain() { }, config: { swr: { - refreshInterval: secondsInMilliseconds(60), + refreshInterval: defaultDatasetRefreshInterval, }, }, }) const pending = useWalletPending({ config: { swr: { - refreshInterval: secondsInMilliseconds(60), + refreshInterval: defaultDatasetRefreshInterval, }, }, }) diff --git a/apps/hostd/contexts/volumes/index.tsx b/apps/hostd/contexts/volumes/index.tsx index cf8318097..6c96458fa 100644 --- a/apps/hostd/contexts/volumes/index.tsx +++ b/apps/hostd/contexts/volumes/index.tsx @@ -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 { @@ -36,7 +37,7 @@ function useVolumesMain() { refreshInterval: (data) => data?.find((v) => isOperationInProgress(v)) ? secondsInMilliseconds(5) - : secondsInMilliseconds(60), + : defaultDatasetRefreshInterval, }, }, }) diff --git a/apps/hostd/dialogs/AlertsDialog.tsx b/apps/hostd/dialogs/AlertsDialog.tsx index 396c1ca98..ae8ea407b 100644 --- a/apps/hostd/dialogs/AlertsDialog.tsx +++ b/apps/hostd/dialogs/AlertsDialog.tsx @@ -12,6 +12,7 @@ import { } from '@siafoundation/react-hostd' import { humanTime } from '@siafoundation/units' import { useCallback } from 'react' +import { defaultDatasetRefreshInterval } from '../config/swr' type Props = { open: boolean @@ -19,7 +20,13 @@ type Props = { } export function AlertsDialog({ open, onOpenChange }: Props) { - const alerts = useAlerts() + const alerts = useAlerts({ + config: { + swr: { + refreshInterval: defaultDatasetRefreshInterval, + }, + }, + }) const dismiss = useAlertsDismiss() const dismissOne = useCallback( diff --git a/apps/renterd/config/swr.ts b/apps/renterd/config/swr.ts new file mode 100644 index 000000000..23d7e1297 --- /dev/null +++ b/apps/renterd/config/swr.ts @@ -0,0 +1,3 @@ +import { secondsInMilliseconds } from '@siafoundation/design-system' + +export const defaultDatasetRefreshInterval = secondsInMilliseconds(15) diff --git a/apps/renterd/contexts/contracts/index.tsx b/apps/renterd/contexts/contracts/index.tsx index 60943f8fb..e4c42d3b9 100644 --- a/apps/renterd/contexts/contracts/index.tsx +++ b/apps/renterd/contexts/contracts/index.tsx @@ -4,7 +4,6 @@ import { useDatasetEmptyState, useClientFilters, useClientFilteredDataset, - minutesInMilliseconds, daysInMilliseconds, } from '@siafoundation/design-system' import { useRouter } from 'next/router' @@ -36,6 +35,7 @@ import { blockHeightToTime } from '@siafoundation/units' import { useContractMetrics } from './useContractMetrics' import { useContractSetMetrics } from './useContractSetMetrics' import { useContractSetSettings } from '../../hooks/useContractSetSettings' +import { defaultDatasetRefreshInterval } from '../../config/swr' const defaultLimit = 50 @@ -48,7 +48,7 @@ function useContractsMain() { const response = useContractsData({ config: { swr: { - refreshInterval: minutesInMilliseconds(1), + refreshInterval: defaultDatasetRefreshInterval, }, }, }) diff --git a/apps/renterd/contexts/filesDirectory/dataset.tsx b/apps/renterd/contexts/filesDirectory/dataset.tsx index 8c8af5b81..ada6a5954 100644 --- a/apps/renterd/contexts/filesDirectory/dataset.tsx +++ b/apps/renterd/contexts/filesDirectory/dataset.tsx @@ -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 @@ -49,7 +49,7 @@ export function useDataset() { params, config: { swr: { - refreshInterval: minutesInMilliseconds(1), + refreshInterval: defaultDatasetRefreshInterval, }, }, }) diff --git a/apps/renterd/contexts/filesFlat/dataset.tsx b/apps/renterd/contexts/filesFlat/dataset.tsx index 4acb136c2..22be5fb38 100644 --- a/apps/renterd/contexts/filesFlat/dataset.tsx +++ b/apps/renterd/contexts/filesFlat/dataset.tsx @@ -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 @@ -51,7 +49,7 @@ export function useDataset({ sortDirection, sortField, filters }: Props) { payload: params, config: { swr: { - refreshInterval: minutesInMilliseconds(1), + refreshInterval: defaultDatasetRefreshInterval, }, }, }) diff --git a/apps/renterd/contexts/hosts/index.tsx b/apps/renterd/contexts/hosts/index.tsx index bc4f0f67a..0f76ee081 100644 --- a/apps/renterd/contexts/hosts/index.tsx +++ b/apps/renterd/contexts/hosts/index.tsx @@ -4,7 +4,6 @@ import { useServerFilters, triggerErrorToast, truncate, - minutesInMilliseconds, } from '@siafoundation/design-system' import { HostsSearchFilterMode, @@ -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 @@ -83,7 +83,7 @@ function useHostsMain() { swr: { // before autopilot is configured this will repeatedly 500 errorRetryInterval: 20_000, - refreshInterval: minutesInMilliseconds(1), + refreshInterval: defaultDatasetRefreshInterval, }, }, }) @@ -103,7 +103,7 @@ function useHostsMain() { }, config: { swr: { - refreshInterval: minutesInMilliseconds(1), + refreshInterval: defaultDatasetRefreshInterval, }, }, }) diff --git a/apps/renterd/contexts/keys/index.tsx b/apps/renterd/contexts/keys/index.tsx index e790b2e99..4f06ff141 100644 --- a/apps/renterd/contexts/keys/index.tsx +++ b/apps/renterd/contexts/keys/index.tsx @@ -3,7 +3,6 @@ import { useDatasetEmptyState, useClientFilters, useClientFilteredDataset, - minutesInMilliseconds, } from '@siafoundation/design-system' import { useRouter } from 'next/router' import { createContext, useContext, useMemo } from 'react' @@ -15,6 +14,7 @@ import { } from './types' import { columns } from './columns' import { useS3AuthenticationSettings } from '../../hooks/useS3AuthenticationSettings' +import { defaultDatasetRefreshInterval } from '../../config/swr' const defaultLimit = 50 @@ -25,7 +25,7 @@ function useKeysMain() { const response = useS3AuthenticationSettings({ config: { swr: { - refreshInterval: minutesInMilliseconds(1), + refreshInterval: defaultDatasetRefreshInterval, }, }, }) diff --git a/apps/renterd/contexts/transactions/index.tsx b/apps/renterd/contexts/transactions/index.tsx index 5bc561332..046dd36f4 100644 --- a/apps/renterd/contexts/transactions/index.tsx +++ b/apps/renterd/contexts/transactions/index.tsx @@ -2,7 +2,6 @@ import { TxType, daysInMilliseconds, getTransactionType, - secondsInMilliseconds, stripPrefix, useDatasetEmptyState, } from '@siafoundation/design-system' @@ -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 = [] @@ -54,7 +54,7 @@ function useTransactionsMain() { }, config: { swr: { - refreshInterval: secondsInMilliseconds(60), + refreshInterval: defaultDatasetRefreshInterval, }, }, }) @@ -62,7 +62,7 @@ function useTransactionsMain() { const pending = useWalletPending({ config: { swr: { - refreshInterval: secondsInMilliseconds(60), + refreshInterval: defaultDatasetRefreshInterval, }, }, }) diff --git a/apps/renterd/dialogs/AlertsDialog.tsx b/apps/renterd/dialogs/AlertsDialog.tsx index e524c89fe..92169f120 100644 --- a/apps/renterd/dialogs/AlertsDialog.tsx +++ b/apps/renterd/dialogs/AlertsDialog.tsx @@ -28,6 +28,7 @@ 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 @@ -35,7 +36,13 @@ type Props = { } export function AlertsDialog({ open, onOpenChange }: Props) { - const alerts = useAlerts() + const alerts = useAlerts({ + config: { + swr: { + refreshInterval: defaultDatasetRefreshInterval, + }, + }, + }) const dismiss = useAlertsDismiss() const dismissOne = useCallback( diff --git a/apps/walletd/config/swr.ts b/apps/walletd/config/swr.ts new file mode 100644 index 000000000..23d7e1297 --- /dev/null +++ b/apps/walletd/config/swr.ts @@ -0,0 +1,3 @@ +import { secondsInMilliseconds } from '@siafoundation/design-system' + +export const defaultDatasetRefreshInterval = secondsInMilliseconds(15) diff --git a/apps/walletd/contexts/addresses/index.tsx b/apps/walletd/contexts/addresses/index.tsx index a18627a21..c2dce8f5b 100644 --- a/apps/walletd/contexts/addresses/index.tsx +++ b/apps/walletd/contexts/addresses/index.tsx @@ -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() @@ -28,6 +29,11 @@ export function useAddressesMain() { params: { id: walletId, }, + config: { + swr: { + refreshInterval: defaultDatasetRefreshInterval, + }, + }, }) const dataset = useMemo(() => { diff --git a/apps/walletd/contexts/events/index.tsx b/apps/walletd/contexts/events/index.tsx index 32daaa765..ddad87dd9 100644 --- a/apps/walletd/contexts/events/index.tsx +++ b/apps/walletd/contexts/events/index.tsx @@ -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 @@ -41,6 +42,11 @@ export function useEventsMain() { params: { id, }, + config: { + swr: { + refreshInterval: defaultDatasetRefreshInterval, + }, + }, }) const responseEvents = useWalletEvents({ disabled: !id, @@ -49,6 +55,11 @@ export function useEventsMain() { offset, id, }, + config: { + swr: { + refreshInterval: defaultDatasetRefreshInterval, + }, + }, }) const walletSub = useWalletSubscribe() diff --git a/apps/walletd/contexts/wallets/index.tsx b/apps/walletd/contexts/wallets/index.tsx index 4b18f6e3f..458848b45 100644 --- a/apps/walletd/contexts/wallets/index.tsx +++ b/apps/walletd/contexts/wallets/index.tsx @@ -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() diff --git a/apps/walletd/hooks/useWalletAddresses.tsx b/apps/walletd/hooks/useWalletAddresses.tsx index 1c6bbae58..2e78bb8b8 100644 --- a/apps/walletd/hooks/useWalletAddresses.tsx +++ b/apps/walletd/hooks/useWalletAddresses.tsx @@ -1,6 +1,7 @@ import { useDatasetEmptyState } from '@siafoundation/design-system' import { useWalletAddresses as useData } from '@siafoundation/react-walletd' import { useMemo } from 'react' +import { defaultDatasetRefreshInterval } from '../config/swr' type AddressData = { id: string @@ -22,6 +23,11 @@ export function useWalletAddresses({ id }: { id: string }) { params: { id, }, + config: { + swr: { + refreshInterval: defaultDatasetRefreshInterval, + }, + }, }) const dataset = useMemo(() => {