From 8b1480589f31efe15500c45a94ded18f1e419be6 Mon Sep 17 00:00:00 2001 From: Rafael Taranto Date: Wed, 17 Apr 2019 20:27:58 -0300 Subject: [PATCH] Add new unseen tx screen --- lib/route-helpers.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/route-helpers.js b/lib/route-helpers.js index ce43e322..857dded8 100644 --- a/lib/route-helpers.js +++ b/lib/route-helpers.js @@ -56,6 +56,7 @@ function fetchPhoneTx (phone) { return db.any(sql, values) .then(_.map(toCashOutTx)) .then(txs => { + const seenTxs = _.some(it => it.status !== 'notSeen', txs) const confirmedTxs = txs.filter(tx => _.includes(tx.status, ['instant', 'confirmed'])) if (confirmedTxs.length > 0) { const reducer = (acc, val) => { @@ -67,7 +68,8 @@ function fetchPhoneTx (phone) { return maxTx } - if (txs.length > 0) throw httpError('Pending transactions', 412) + if (txs.length > 0 && !seenTxs) throw httpError('Transaction not seen', 411) + if (txs.length > 0 && seenTxs) throw httpError('Pending transactions', 412) throw httpError('No transactions', 404) }) }