Update TransactionListItem.tsx

This commit is contained in:
Marcos Rodriguez Velez 2025-02-20 19:32:22 -04:00
parent 1b328cd130
commit d610063809

View file

@ -246,7 +246,19 @@ export const TransactionListItem: React.FC<TransactionListItemProps> = React.mem
setSubtitleNumberOfLines(0);
}, []);
const subtitleProps = useMemo(() => ({ numberOfLines: subtitleNumberOfLines }), [subtitleNumberOfLines]);
const handleOnDetailsPress = useCallback(() => {
if (walletID && item && item.hash) {
navigate('TransactionDetails', { tx: item, hash: item.hash, walletID });
} else {
const lightningWallet = wallets.find(wallet => wallet?.getID() === item.walletID);
if (lightningWallet) {
navigate('LNDViewInvoice', {
invoice: item,
walletID: lightningWallet.getID(),
});
}
}
}, [item, navigate, walletID, wallets]);
const handleOnCopyAmountTap = useCallback(() => Clipboard.setString(rowTitle.replace(/[\s\\-]/g, '')), [rowTitle]);
const handleOnCopyTransactionID = useCallback(() => Clipboard.setString(item.hash), [item.hash]);
@ -277,6 +289,8 @@ export const TransactionListItem: React.FC<TransactionListItemProps> = React.mem
handleCopyOpenInBlockExplorerPress();
} else if (id === CommonToolTipActions.CopyTXID.id) {
handleOnCopyTransactionID();
} else if (id === CommonToolTipActions.Details.id) {
handleOnDetailsPress();
}
},
[
@ -284,31 +298,40 @@ export const TransactionListItem: React.FC<TransactionListItemProps> = React.mem
handleOnCopyAmountTap,
handleOnCopyNote,
handleOnCopyTransactionID,
handleOnDetailsPress,
handleOnExpandNote,
handleOnViewOnBlockExplorer,
],
);
const toolTipActions = useMemo((): Action[] => {
const actions: (Action | Action[])[] = [];
if (rowTitle !== loc.lnd.expired) {
actions.push(CommonToolTipActions.CopyAmount);
}
if (subtitle) {
actions.push(CommonToolTipActions.CopyNote);
}
if (item.hash) {
actions.push(CommonToolTipActions.CopyTXID, CommonToolTipActions.CopyBlockExplorerLink, [CommonToolTipActions.OpenInBlockExplorer]);
}
if (subtitle && subtitleNumberOfLines === 1) {
actions.push([CommonToolTipActions.ExpandNote]);
}
const actions: (Action | Action[])[] = [
{
...CommonToolTipActions.CopyAmount,
hidden: rowTitle === loc.lnd.expired,
},
{
...CommonToolTipActions.CopyNote,
hidden: !subtitle,
},
{
...CommonToolTipActions.CopyTXID,
hidden: !item.hash,
},
{
...CommonToolTipActions.CopyBlockExplorerLink,
hidden: !item.hash,
},
[{ ...CommonToolTipActions.OpenInBlockExplorer, hidden: !item.hash }, CommonToolTipActions.Details],
[
{
...CommonToolTipActions.ExpandNote,
hidden: subtitleNumberOfLines !== 1,
},
],
];
return actions as Action[];
}, [item.hash, subtitle, rowTitle, subtitleNumberOfLines]);
}, [rowTitle, subtitle, item.hash, subtitleNumberOfLines]);
const accessibilityState = useMemo(() => {
return {
@ -316,6 +339,8 @@ export const TransactionListItem: React.FC<TransactionListItemProps> = React.mem
};
}, [subtitleNumberOfLines]);
const subtitleProps = useMemo(() => ({ numberOfLines: subtitleNumberOfLines }), [subtitleNumberOfLines]);
return (
<ToolTipMenu
isButton
@ -341,4 +366,4 @@ export const TransactionListItem: React.FC<TransactionListItemProps> = React.mem
</ToolTipMenu>
);
},
);
);