Skip to content

Commit

Permalink
trim long desriptions on home view
Browse files Browse the repository at this point in the history
  • Loading branch information
niteshbalusu11 committed Jul 10, 2024
1 parent b5feea1 commit e9a4960
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/components/TransactionCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,18 @@ export default function TransactionCard({ onPress, transaction, unit }: IProps)
}
}

const getDescription = () => {
if (!description || !description.length) {
return "No description";
}

if (description.length > 50) {
return `${description.substring(0, 100)}...`;
}

return description;
};

return (
<Card>
<CardItem activeOpacity={1} button={true} onPress={() => onPress(transaction.rHash)}>
Expand Down Expand Up @@ -158,7 +170,7 @@ export default function TransactionCard({ onPress, transaction, unit }: IProps)
{recipientOrSender}:{" "}
</Text>
)}
{description && description.length !== 0 ? description : "No description"}
{getDescription()}
</Text>
<Text note={true} style={transactionStyle.status}>
{statusLabel}
Expand Down

0 comments on commit e9a4960

Please sign in to comment.