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

Commit

Permalink
removed #fetchLastTx function
Browse files Browse the repository at this point in the history
  • Loading branch information
witoldsz committed Sep 1, 2018
1 parent 4cf6f89 commit b1218bf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
6 changes: 0 additions & 6 deletions front/src/main/model/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,6 @@ export async function fetchTxs(address: string, from: number, to: number): Promi
})))
}

export async function fetchLastTxs(account: AccountType, { page, size }: { page: number, size: number }) {
const to = account.transactionCount - size * page
const from = Math.max(0, to - size)
return fetchTxs(account.address, from, to)
}

export async function fetchPendingTxs(address: string): Promise<TransactionType[]> {
const path = `/v2.1.0/account/pending-transactions?address=${address}&from=0&to=999`
const remotes = await exec<PendingTransactionTypeRemote[]>('GET', path)
Expand Down
11 changes: 9 additions & 2 deletions front/src/main/panels/home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import { ZERO, concat } from '../lib/utils'
import { BlockType, fetchLatestBlock } from '../model/block'
import { AccountType, fetchAccount } from '../model/account'
import { Maybe, maybe } from 'tsmonad'
import { fetchLastTxs, TransactionType, caseTypeOf } from '../model/transaction'
import { TransactionType, caseTypeOf, fetchTxs } from '../model/transaction'
import { localeDateTime, transfer, sem, addressAbbr } from '../lib/format'
import { addresses, address1st, WalletState } from '../model/wallet'
import { calculateRange } from '../lib/pagination'

const MAX_TXS_SIZE = 5
const FETCH_INTERVAL = 20000
Expand All @@ -30,7 +31,13 @@ export const initialHomeState: HomeState = {
type AccountAndTxs = [AccountType, TransactionType[]]
async function fetchAccAndTxs(address: string): Promise<AccountAndTxs> {
const account = await fetchAccount(address)
const transactions = await fetchLastTxs(account, { page: 0, size: MAX_TXS_SIZE })
const pageRange = calculateRange({
totalCount: account.transactionCount,
pageNumber: 0,
pageSize: MAX_TXS_SIZE,
dir: 'Desc',
})
const transactions = await fetchTxs(account.address, pageRange.from, pageRange.to)
return [account, transactions]
}

Expand Down

0 comments on commit b1218bf

Please sign in to comment.