Disable utf8 display when impossible to decode

This commit is contained in:
Willian Mitsuda 2021-11-08 14:55:41 -03:00
parent d905afd75d
commit 05aee02a43
1 changed files with 3 additions and 4 deletions

View File

@ -30,9 +30,8 @@ const InputDecoder: React.FC<InputDecoderProps> = ({
try { try {
return toUtf8String(data); return toUtf8String(data);
} catch (err) { } catch (err) {
console.warn("Error while converting input data to string"); // Silently ignore on purpose
console.warn(err); return undefined;
return "<can't decode>";
} }
}, [data]); }, [data]);
@ -41,7 +40,7 @@ const InputDecoder: React.FC<InputDecoderProps> = ({
<Tab.List className="flex space-x-1 mb-1"> <Tab.List className="flex space-x-1 mb-1">
<ModeTab disabled={!resolvedTxDesc}>Decoded</ModeTab> <ModeTab disabled={!resolvedTxDesc}>Decoded</ModeTab>
<ModeTab>Raw</ModeTab> <ModeTab>Raw</ModeTab>
<ModeTab>UTF-8</ModeTab> <ModeTab disabled={utfInput === undefined}>UTF-8</ModeTab>
</Tab.List> </Tab.List>
<Tab.Panels> <Tab.Panels>
<Tab.Panel> <Tab.Panel>