Skip to content
Snippets Groups Projects
Commit d676dba0 authored by Lukas's avatar Lukas Committed by mcfarhat
Browse files

Fix trx count on head block card

parent 04e1d0c0
No related branches found
No related tags found
1 merge request!602Lbudginas/#497 live data block info bug
...@@ -39,8 +39,15 @@ export default function Home() { ...@@ -39,8 +39,15 @@ export default function Home() {
const { blockOperations } = useBlockOperations(headBlockNum || 0); const { blockOperations } = useBlockOperations(headBlockNum || 0);
// Filter operations that have a trx_id // Filter operations that have a trx_id
const trxOperations = blockOperations?.operations_result.filter( const trxOperations = blockOperations?.operations_result.reduce(
(operation) => operation.trx_id (max, operation) => {
if (typeof operation?.trx_in_block === "number") {
return Math.max(max, operation.trx_in_block);
} else {
return max;
}
},
0
); );
const [opcount, setOpcount] = useState<number>(0); const [opcount, setOpcount] = useState<number>(0);
...@@ -51,10 +58,10 @@ export default function Home() { ...@@ -51,10 +58,10 @@ export default function Home() {
setOpcount(blockOperations?.total_operations); setOpcount(blockOperations?.total_operations);
} }
if (trxOperations) { if (trxOperations) {
setTrxOpLength(trxOperations.length); setTrxOpLength(trxOperations + 1);
} }
// eslint-disable-next-line react-hooks/exhaustive-deps // eslint-disable-next-line react-hooks/exhaustive-deps
}, [blockOperations?.total_operations, trxOperations?.length]); }, [blockOperations?.total_operations, trxOperations]);
const strokeColor = theme === "dark" ? "#FFF" : "#000"; const strokeColor = theme === "dark" ? "#FFF" : "#000";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment