Avoid showing pending transactions, when latestBlock is not defined

pull/2/head
Michael Scoff 7 years ago
parent d1b62eedb5
commit 1b639c9893
  1. 9
      Trust/Transactions/ViewModels/TransactionCellViewModel.swift

@ -15,17 +15,18 @@ struct TransactionCellViewModel {
self.transaction = transaction self.transaction = transaction
self.chainState = chainState self.chainState = chainState
} }
var confirmations: Int { var confirmations: Int {
return max(chainState.latestBlock - Int(transaction.blockNumber), 0) return max(chainState.latestBlock - Int(transaction.blockNumber), 0)
} }
private var state: TransactionState { var state: TransactionState {
if confirmations == 0 {
return .pending
}
if transaction.isError { if transaction.isError {
return .error return .error
} }
if confirmations == 0 && chainState.latestBlock >= transaction.blockNumber {
return .pending
}
return .completed return .completed
} }

Loading…
Cancel
Save