Skip to content

Commit

Permalink
Increase before param to avoid exclusive filtering in Nexus
Browse files Browse the repository at this point in the history
  • Loading branch information
buberdds committed Oct 3, 2024
1 parent 17b03ca commit 7ab0175
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/app/hooks/useListBeforeDate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,26 @@ import { Layer, useGetRuntimeStatus, useGetStatus } from '../../oasis-nexus/api'
import { AppError, AppErrors } from 'types/errors'
import { SearchScope } from 'types/searchScope'

function addOneSecond(timestamp: string | undefined) {
if (!timestamp) {
return undefined
}
const date = new Date(timestamp)
date.setSeconds(date.getSeconds() + 1)
return date.toISOString()
}

const useListBeforeDate = (
latestBlockTime: string | undefined,
offset: number,
setOffsetAssociatedWithDate: (offset: number) => void,
) => {
const [beforeDate, setBeforeDate] = useState<string | undefined>(undefined)
const setBeforeDateFromCollection = (newDate: string | undefined) => {
if (offset === 0 && beforeDate !== newDate) {
setBeforeDate(newDate)
const adjustedDate = addOneSecond(newDate)
// workaround around "before" filter exclusive maximum transaction time.
if (offset === 0 && beforeDate !== adjustedDate) {
setBeforeDate(adjustedDate)
}
}

Expand Down

0 comments on commit 7ab0175

Please sign in to comment.