From 1b639c98933819bdf22283e822560087e8514c6b Mon Sep 17 00:00:00 2001 From: Michael Scoff Date: Thu, 16 Nov 2017 21:50:23 -0800 Subject: [PATCH] Avoid showing pending transactions, when latestBlock is not defined --- .../ViewModels/TransactionCellViewModel.swift | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Trust/Transactions/ViewModels/TransactionCellViewModel.swift b/Trust/Transactions/ViewModels/TransactionCellViewModel.swift index c79e8271a..535213da0 100644 --- a/Trust/Transactions/ViewModels/TransactionCellViewModel.swift +++ b/Trust/Transactions/ViewModels/TransactionCellViewModel.swift @@ -15,17 +15,18 @@ struct TransactionCellViewModel { self.transaction = transaction self.chainState = chainState } + var confirmations: Int { return max(chainState.latestBlock - Int(transaction.blockNumber), 0) } - private var state: TransactionState { - if confirmations == 0 { - return .pending - } + var state: TransactionState { if transaction.isError { return .error } + if confirmations == 0 && chainState.latestBlock >= transaction.blockNumber { + return .pending + } return .completed }