Skip to content

Commit

Permalink
refactor: improve naming
Browse files Browse the repository at this point in the history
  • Loading branch information
kathaypacific committed Aug 12, 2022
1 parent 6fb61bf commit 5f42507
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/transactions/feed/queryHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ export function useFetchTransactions(): QueryHookResult {
const [fetchedResult, setFetchedResult] = useState<{
transactions: TokenTransaction[]
pageInfo: PageInfo | null
hasReturnedTransactions: boolean
hasTransactionsOnCurrentPage: boolean
}>({
transactions: [],
pageInfo: null,
hasReturnedTransactions: false,
hasTransactionsOnCurrentPage: false,
})
const [fetchingMoreTransactions, setFetchingMoreTransactions] = useState(false)

Expand All @@ -94,8 +94,8 @@ export function useFetchTransactions(): QueryHookResult {
// avoid updating pageInfo and hasReturnedTransactions for polled
// updates, as these variables are used for fetching the next pages
pageInfo: isPolledUpdate ? prev.pageInfo : returnedPageInfo,
hasReturnedTransactions: isPolledUpdate
? prev.hasReturnedTransactions
hasTransactionsOnCurrentPage: isPolledUpdate
? prev.hasTransactionsOnCurrentPage
: returnedTransactions.length > 0,
}))

Expand Down Expand Up @@ -160,11 +160,11 @@ export function useFetchTransactions(): QueryHookResult {
// 2. sometimes blockchain-api returns 0 transactions for a page (as we only
// display certain transaction types in the app) and for this case,
// automatically fetch the next page(s) until some transactions are returned
const { transactions, pageInfo, hasReturnedTransactions } = fetchedResult
const { transactions, pageInfo, hasTransactionsOnCurrentPage } = fetchedResult
if (
!loading &&
pageInfo?.hasNextPage &&
(transactions.length < MIN_NUM_TRANSACTIONS || !hasReturnedTransactions)
(transactions.length < MIN_NUM_TRANSACTIONS || !hasTransactionsOnCurrentPage)
) {
setFetchingMoreTransactions(true)
}
Expand Down

0 comments on commit 5f42507

Please sign in to comment.