Display '<empty>' for U8a which is isEmpty (not the default) (#716)

This commit is contained in:
Jaco Greeff 2019-02-14 13:26:23 +01:00 committed by GitHub
parent 5785d71d90
commit ba5ecc2205
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -7,6 +7,7 @@ import './Params.css';
import React from 'react';
import { classes } from '@polkadot/ui-app/util';
import { isNull, isUndefined, u8aToHex } from '@polkadot/util';
import { U8a } from '@polkadot/types';
// import IdentityIcon from '@polkadot/ui-react/IdentityIcon';
// import formatNumber from '@polkadot/ui-app/util/formatNumber';
@ -150,13 +151,22 @@ function valueToText (type: string, value: any, swallowError: boolean = true, co
// }
// }
// dont' even ask, nested ?: ... really?
return isNull(value) || isUndefined(value)
? unknown
: div(
{},
['Bytes', 'Data'].includes(type)
? u8aToHex(value.toU8a(true), contentShorten ? 512 : -1)
: value.toString()
: (
value instanceof U8a
? (
value.isEmpty
? '<empty>'
: value.toString()
)
: value.toString()
)
);
}