Skip to content

Commit 74ef7b0

Browse files
author
Lucas Araujo
committed
[DDW-942] Display ascii name when name is missing
1 parent 7096a23 commit 74ef7b0

File tree

2 files changed

+25
-6
lines changed

2 files changed

+25
-6
lines changed

source/renderer/app/components/assets/Asset.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@
7575
overflow: hidden;
7676
text-overflow: ellipsis;
7777
white-space: nowrap;
78+
79+
&.ascii {
80+
color: var(--theme-tokens-list-header-text-color);
81+
}
7882
}
7983

8084
.metadata {

source/renderer/app/components/assets/Asset.tsx

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { PopOver } from 'react-polymorph/lib/components/PopOver';
55
import { defineMessages, intlShape } from 'react-intl';
66
import { observer } from 'mobx-react';
77
import styles from './Asset.scss';
8-
import { ellipsis } from '../../utils/strings';
8+
import { ellipsis, hexToString } from '../../utils/strings';
99
import AssetContent from './AssetContent';
1010
import settingsIcon from '../../assets/images/asset-token-settings-ic.inline.svg';
1111
import warningIcon from '../../assets/images/asset-token-warning-ic.inline.svg';
@@ -173,8 +173,18 @@ class Asset extends Component<Props, State> {
173173
hasWarning,
174174
hasError,
175175
} = this.props;
176-
const { fingerprint, metadata, decimals, recommendedDecimals } = asset;
177-
const { name } = metadata || {};
176+
const {
177+
fingerprint,
178+
metadata,
179+
decimals,
180+
recommendedDecimals,
181+
assetName,
182+
} = asset;
183+
const hasName = !!metadata?.name;
184+
const name = metadata?.name || `ASCII: ${hexToString(assetName)}`;
185+
const displayName = metadataNameChars
186+
? ellipsis(name, metadataNameChars)
187+
: name;
178188
const contentStyles = classnames([
179189
styles.pill,
180190
hasError ? styles.error : null,
@@ -196,9 +206,14 @@ class Asset extends Component<Props, State> {
196206
? fingerprint
197207
: ellipsis(fingerprint || '', startCharAmount, endCharAmount)}
198208
</div>
199-
{name && (
200-
<div className={styles.metadataName}>
201-
{metadataNameChars ? ellipsis(name, metadataNameChars) : name}
209+
{displayName && (
210+
<div
211+
className={classnames(
212+
styles.metadataName,
213+
!hasName && styles.ascii
214+
)}
215+
>
216+
{displayName}
202217
</div>
203218
)}
204219
{hasWarning && (

0 commit comments

Comments
 (0)