Skip to content

Commit

Permalink
Adjust view of the long address
Browse files Browse the repository at this point in the history
  • Loading branch information
Wolmin committed Nov 21, 2023
1 parent 746ae38 commit ce55df9
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions lib/shortenUniversalProfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ export default function shortenUniversalProfile(string: string | null) {
return string;
}

const upParts = string.split('#');
const hashHead = '#' + upParts[1].slice(2, 6); // change #0x1234 -> #1234
const upParts = string.split(' (');
const hashHead = '#' + upParts[1].slice(2, 6); // change (0x1234) -> #1234

return string.slice(0, 3) + '...' + hashHead;
return string.slice(0, 2) + '...' + hashHead;
}
2 changes: 1 addition & 1 deletion ui/shared/HashStringShorten.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const HashStringShorten = ({ hash, isTooltipDisabled, as = 'span' }: Props) => {
if (identiconType === undefined) {
return undefined;
}
if (identiconType.includes('universal_profile') && hash.includes('#')) {
if (identiconType.includes('universal_profile') && hash.includes(' (')) {
setShortenedString(shortenUniversalProfile(hash));
}
}, [ hash ]);
Expand Down
10 changes: 5 additions & 5 deletions ui/shared/HashStringShortenDynamic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,12 @@ const HashStringShortenDynamic = ({ hash, fontWeight = '400', isTooltipDisabled,
if (identiconType === undefined) {
return;
}
if (identiconType.includes('universal_profile') && hash.includes('#')) {
const upParts = hash.split('#');
const hashHead = '#' + upParts[1].slice(2, 6); // change #0x1234 -> #1234
if (identiconType.includes('universal_profile') && hash.includes(' (')) {
const upParts = hash.split(' (');
const hashHead = '#' + upParts[1].slice(2, 6); // change (0x1234...5678) -> #1234
const name = upParts[0];
const slicedName = name.slice(0, rightI - 2);
const displayed = rightI - 2 > name.length ? name + hashHead : slicedName + '...' + hashHead;
const slicedName = name.slice(0, rightI - 3);
const displayed = rightI - 3 > name.length ? name + hashHead : slicedName + '...' + hashHead;
setDisplayedString(displayed);

return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ interface Props {
}

export const formattedLuksoName = (hash: string, name: string) => {
return `@${ name }#${ hash }`;
return `@${ name } (${ hash })`;
};

export const getUniversalProfile = async(address: string, queryClient: QueryClient) => {
Expand Down

0 comments on commit ce55df9

Please sign in to comment.