From 1bf1d5cf2c138f03f37944d3db375b530b40351c Mon Sep 17 00:00:00 2001 From: lukaw3d Date: Mon, 21 Aug 2023 23:28:23 +0200 Subject: [PATCH] Fix variable names in useRuntimeFreshness --- .changelog/811.internal.md | 1 + src/app/components/OfflineBanner/hook.ts | 9 ++++----- 2 files changed, 5 insertions(+), 5 deletions(-) create mode 100644 .changelog/811.internal.md diff --git a/.changelog/811.internal.md b/.changelog/811.internal.md new file mode 100644 index 000000000..cc2cdc411 --- /dev/null +++ b/.changelog/811.internal.md @@ -0,0 +1 @@ +Fix variable names in useRuntimeFreshness diff --git a/src/app/components/OfflineBanner/hook.ts b/src/app/components/OfflineBanner/hook.ts index 394aa34c2..cce6efb4c 100644 --- a/src/app/components/OfflineBanner/hook.ts +++ b/src/app/components/OfflineBanner/hook.ts @@ -26,7 +26,8 @@ export const useRuntimeFreshness = (scope: SearchScope): FreshnessInfo => { throw new AppError(AppErrors.UnsupportedLayer) } const query = useGetRuntimeStatus(scope.network, scope.layer) - const timeDistance = useFormattedTimestampString(query?.data?.data.latest_block_time) + const data = query.data?.data + const lastUpdate = useFormattedTimestampString(data?.latest_block_time) if (query.isError) { return { @@ -48,14 +49,12 @@ export const useRuntimeFreshness = (scope: SearchScope): FreshnessInfo => { outOfDate: false, } } - const data = query.data?.data if (!query.isSuccess || !data) { return { outOfDate: true, } } - const { latest_block } = data - if (latest_block === -1) { + if (data.latest_block === -1) { return { outOfDate: true, } @@ -64,6 +63,6 @@ export const useRuntimeFreshness = (scope: SearchScope): FreshnessInfo => { const { outOfDateThreshold } = paraTimesConfig[scope.layer] return { outOfDate: timeSinceLastUpdate > outOfDateThreshold, - lastUpdate: timeDistance, + lastUpdate: lastUpdate, } }