From a4bc793cf1ceb52e11c4abc0a55875faa621bd82 Mon Sep 17 00:00:00 2001 From: nickofolas <60761231+nickofolas@users.noreply.github.com> Date: Fri, 8 Apr 2022 10:21:40 -0500 Subject: [PATCH] Hide SF display when no SFs owned --- src/Augmentation/ui/SourceFiles.tsx | 151 ++++++++++++++-------------- 1 file changed, 73 insertions(+), 78 deletions(-) diff --git a/src/Augmentation/ui/SourceFiles.tsx b/src/Augmentation/ui/SourceFiles.tsx index d52e4590a..895119091 100644 --- a/src/Augmentation/ui/SourceFiles.tsx +++ b/src/Augmentation/ui/SourceFiles.tsx @@ -65,99 +65,94 @@ export function SourceFilesElement(): React.ReactElement { const [selectedSf, setSelectedSf] = useState(sourceSfs[0]); + if (sourceSfs.length === 0) { + return <>; + } + return ( Source Files - {sourceSfs.length > 0 ? ( - - - - {exploits.length > 0 && ( - setSelectedSf({ n: -1, lvl: exploits.length })} - selected={selectedSf.n === -1} - sx={{ py: 0 }} - > + + + + {exploits.length > 0 && ( + setSelectedSf({ n: -1, lvl: exploits.length })} + selected={selectedSf.n === -1} + sx={{ py: 0 }} + > + Source-File -1: Exploits in the BitNodes} + secondary={ + + Level {exploits.length} / {Object.keys(Exploit).length} + + } + /> + + )} + + {sourceSfs.map((e, i) => { + const sfObj = safeGetSf(e.n); + if (!sfObj) return; + const maxLevel = sfObj?.n === 12 ? "∞" : "3"; + + return ( + setSelectedSf(e)} selected={selectedSf === e} sx={{ py: 0 }}> Source-File -1: Exploits in the BitNodes} + primary={{sfObj.name}} secondary={ - Level {exploits.length} / {Object.keys(Exploit).length} + Level {e.lvl} / {maxLevel} } /> - )} + ); + })} + + + + + {safeGetSf(selectedSf.n)?.name} + + + {(() => { + const sfObj = safeGetSf(selectedSf.n); + if (!sfObj) return; - {sourceSfs.map((e, i) => { - const sfObj = safeGetSf(e.n); - if (!sfObj) return; - const maxLevel = sfObj?.n === 12 ? "∞" : "3"; + let maxLevel; + switch (sfObj?.n) { + case 12: + maxLevel = "∞"; + break; + case -1: + maxLevel = Object.keys(Exploit).length; + break; + default: + maxLevel = "3"; + } - return ( - setSelectedSf(e)} - selected={selectedSf === e} - sx={{ py: 0 }} - > - {sfObj.name}} - secondary={ - - Level {e.lvl} / {maxLevel} - - } - /> - - ); - })} - - - - - {safeGetSf(selectedSf.n)?.name} - - - {(() => { - const sfObj = safeGetSf(selectedSf.n); - if (!sfObj) return; - - let maxLevel; - switch (sfObj?.n) { - case 12: - maxLevel = "∞"; - break; - case -1: - maxLevel = Object.keys(Exploit).length; - break; - default: - maxLevel = "3"; - } - - return ( - <> - Level {selectedSf.lvl} / {maxLevel} -
-
- {sfObj?.info} - - ); - })()} -
-
-
- ) : ( - <> - )} + return ( + <> + Level {selectedSf.lvl} / {maxLevel} +
+
+ {sfObj?.info} + + ); + })()} + +
+ ); }