Skip to content

Commit

Permalink
Fix variable names in useRuntimeFreshness
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaw3d committed Aug 21, 2023
1 parent 68b5e19 commit a6ba95f
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/app/components/OfflineBanner/hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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,
}
Expand All @@ -64,6 +63,6 @@ export const useRuntimeFreshness = (scope: SearchScope): FreshnessInfo => {
const { outOfDateThreshold } = paraTimesConfig[scope.layer]
return {
outOfDate: timeSinceLastUpdate > outOfDateThreshold,
lastUpdate: timeDistance,
lastUpdate: lastUpdate,
}
}

0 comments on commit a6ba95f

Please sign in to comment.