From 8d44d31cb32c5b70bfc33126b3e7309c7a34cc82 Mon Sep 17 00:00:00 2001 From: yann300 Date: Thu, 24 Jun 2021 14:42:14 +0200 Subject: [PATCH] refactor --- .../src/lib/vm-debugger/assembly-items.tsx | 41 ++++--------------- 1 file changed, 8 insertions(+), 33 deletions(-) diff --git a/libs/remix-ui/debugger-ui/src/lib/vm-debugger/assembly-items.tsx b/libs/remix-ui/debugger-ui/src/lib/vm-debugger/assembly-items.tsx index 3f1a4c5235..af6c061e6c 100644 --- a/libs/remix-ui/debugger-ui/src/lib/vm-debugger/assembly-items.tsx +++ b/libs/remix-ui/debugger-ui/src/lib/vm-debugger/assembly-items.tsx @@ -28,19 +28,7 @@ export const AssemblyItems = ({ registerEvent }) => { } }, [assemblyItems.opCodes.index]) - const clearItems = () => { - let currentItem = refs.current[selectedItem] ? refs.current[selectedItem] : null - - if (currentItem) { - currentItem.removeAttribute('selected') - currentItem.removeAttribute('style') - if (currentItem.firstChild) { - currentItem.firstChild.removeAttribute('style') - } - } - - currentItem = refs.current[nextSelectedItem] ? refs.current[nextSelectedItem] : null - + let clearItem = (currentItem) => { if (currentItem) { currentItem.removeAttribute('selected') currentItem.removeAttribute('style') @@ -48,33 +36,20 @@ export const AssemblyItems = ({ registerEvent }) => { currentItem.firstChild.removeAttribute('style') } } + } + const clearItems = () => { + clearItem(refs.current[selectedItem] ? refs.current[selectedItem] : null) + clearItem(refs.current[nextSelectedItem] ? refs.current[nextSelectedItem] : null) + returnInstructionIndexes.map((index) => { if (index < 0) return - - currentItem = refs.current[index] ? refs.current[index] : null - - if (currentItem) { - currentItem.removeAttribute('selected') - currentItem.removeAttribute('style') - if (currentItem.firstChild) { - currentItem.firstChild.removeAttribute('style') - } - } + clearItem(refs.current[index] ? refs.current[index] : null) }) outOfGasInstructionIndexes.map((index) => { if (index < 0) return - - currentItem = refs.current[index] ? refs.current[index] : null - - if (currentItem) { - currentItem.removeAttribute('selected') - currentItem.removeAttribute('style') - if (currentItem.firstChild) { - currentItem.firstChild.removeAttribute('style') - } - } + clearItem(refs.current[index] ? refs.current[index] : null) }) }