From ac773cffda1123add5ec304838a34d0fc35ec256 Mon Sep 17 00:00:00 2001 From: Vlad Stan Date: Tue, 11 Oct 2022 14:59:20 +0300 Subject: [PATCH] refactor: simplify code --- .../cashu/templates/cashu/wallet.html | 23 ++++++++----------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/lnbits/extensions/cashu/templates/cashu/wallet.html b/lnbits/extensions/cashu/templates/cashu/wallet.html index 7b5e1c3fb..16f8e1637 100644 --- a/lnbits/extensions/cashu/templates/cashu/wallet.html +++ b/lnbits/extensions/cashu/templates/cashu/wallet.html @@ -524,20 +524,17 @@ page_container %} blindingFactor: t.B_, denomination: t.amount })) - console.log('### x1', x) - x.forEach(t => { - y[`_${t.denomination}`] = y[`_${t.denomination}`] || [] - y[`_${t.denomination}`].push(t) - }) - x = Object.keys(y).map(k => ({ - denomination: y[k][0].denomination, - count: y[k].length, - value: y[k][0].denomination * y[k].length - })) - console.log('### x2', x) - console.log('### y', y) + .reduce((y, t) => { + y[`_${t.denomination}`] = y[`_${t.denomination}`] || [] + y[`_${t.denomination}`].push(t) + return y + }, {}) - return x + return Object.keys(x).map(k => ({ + denomination: x[k][0].denomination, + count: x[k].length, + value: x[k][0].denomination * x[k].length + })) } }, filters: {