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, } }