Skip to content
This repository was archived by the owner on Apr 25, 2023. It is now read-only.

Commit b1218bf

Browse files
committed
removed #fetchLastTx function
1 parent 4cf6f89 commit b1218bf

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

front/src/main/model/transaction.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,6 @@ export async function fetchTxs(address: string, from: number, to: number): Promi
8383
})))
8484
}
8585

86-
export async function fetchLastTxs(account: AccountType, { page, size }: { page: number, size: number }) {
87-
const to = account.transactionCount - size * page
88-
const from = Math.max(0, to - size)
89-
return fetchTxs(account.address, from, to)
90-
}
91-
9286
export async function fetchPendingTxs(address: string): Promise<TransactionType[]> {
9387
const path = `/v2.1.0/account/pending-transactions?address=${address}&from=0&to=999`
9488
const remotes = await exec<PendingTransactionTypeRemote[]>('GET', path)

front/src/main/panels/home.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ import { ZERO, concat } from '../lib/utils'
44
import { BlockType, fetchLatestBlock } from '../model/block'
55
import { AccountType, fetchAccount } from '../model/account'
66
import { Maybe, maybe } from 'tsmonad'
7-
import { fetchLastTxs, TransactionType, caseTypeOf } from '../model/transaction'
7+
import { TransactionType, caseTypeOf, fetchTxs } from '../model/transaction'
88
import { localeDateTime, transfer, sem, addressAbbr } from '../lib/format'
99
import { addresses, address1st, WalletState } from '../model/wallet'
10+
import { calculateRange } from '../lib/pagination'
1011

1112
const MAX_TXS_SIZE = 5
1213
const FETCH_INTERVAL = 20000
@@ -30,7 +31,13 @@ export const initialHomeState: HomeState = {
3031
type AccountAndTxs = [AccountType, TransactionType[]]
3132
async function fetchAccAndTxs(address: string): Promise<AccountAndTxs> {
3233
const account = await fetchAccount(address)
33-
const transactions = await fetchLastTxs(account, { page: 0, size: MAX_TXS_SIZE })
34+
const pageRange = calculateRange({
35+
totalCount: account.transactionCount,
36+
pageNumber: 0,
37+
pageSize: MAX_TXS_SIZE,
38+
dir: 'Desc',
39+
})
40+
const transactions = await fetchTxs(account.address, pageRange.from, pageRange.to)
3441
return [account, transactions]
3542
}
3643

0 commit comments

Comments
 (0)