Skip to content

Commit

Permalink
detect wallet switch / fix percentage formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
NickJ202 committed Jun 26, 2024
1 parent 4dd1e6c commit 51bce5e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
4 changes: 4 additions & 0 deletions src/helpers/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ export function formatPercentage(percentage) {
return `${multiplied.toFixed(0)}%`;
}

if (decimalPart.length > 6) {
return `${multiplied.toFixed(0)}%`;
}

let nonZeroIndex = decimalPart.length;
for (let i = 0; i < decimalPart.length; i++) {
if (decimalPart[i] !== '0') {
Expand Down
4 changes: 3 additions & 1 deletion src/providers/ArweaveProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,13 @@ export function ArweaveProvider(props: ArweaveProviderProps) {
handleWallet();

window.addEventListener('arweaveWalletLoaded', handleWallet);
window.addEventListener('walletSwitch', handleWallet);

return () => {
window.removeEventListener('arweaveWalletLoaded', handleWallet);
window.removeEventListener('walletSwitch', handleWallet);
};
}, [walletType]);
}, []);

React.useEffect(() => {
(async function () {
Expand Down
13 changes: 2 additions & 11 deletions src/views/Profile/ProfileHeader/ProfileHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,9 @@ export default function ProfileHeader(props: IProps) {
})();
}, [props.profile]);

// const copyAddress = React.useCallback(async () => {
// if (props.profile && props.profile.walletAddress) {
// if (props.profile.walletAddress.length > 0) {
// await navigator.clipboard.writeText(props.profile.walletAddress);
// setCopied(true);
// setTimeout(() => setCopied(false), 2000);
// }
// }
// }, [props.profile]);

function getAvatar() {
if (props.profile && props.profile.avatar) return <img src={getTxEndpoint(props.profile.avatar)} />;
if (props.profile && props.profile.avatar && checkValidAddress(props.profile.avatar))
return <img src={getTxEndpoint(props.profile.avatar)} />;
return <ReactSVG src={ASSETS.user} />;
}

Expand Down

0 comments on commit 51bce5e

Please sign in to comment.