fix LbcMessage for single digit integers

This commit is contained in:
Sean Yesmunt 2020-09-17 10:48:25 -04:00
parent 6b8a38b894
commit 40d32a6065
2 changed files with 9 additions and 6 deletions

View file

@ -9,15 +9,18 @@ type Props = {
export default function LbcMessage(props: Props) {
let amount;
const tokenizedMessage = props.children.replace(/(\d?\.?-?\d+?\.?-?\d+?)\s(LBC)/g, (originalString, lbcAmount) => {
const tokenizedMessage = props.children.replace(
/(\d?\.?-?\d?\.?-?\d+?)\s(LBC)/g,
(originalString, lbcAmount, thirdArg) => {
amount = lbcAmount;
return `%lbc%`;
});
}
);
return (
<I18nMessage tokens={{ lbc: amount ? <CreditAmount badge noFormat amount={amount} /> : undefined }}>
{/* Catch any rogue LBC's left */}
{tokenizedMessage.replace(/LBC/g, 'LBRY Credits')}
{tokenizedMessage.replace(/LBC/g, 'Credits')}
</I18nMessage>
);
}

View file

@ -35,7 +35,7 @@ const RewardLink = (props: Props) => {
<Button
button={button ? 'primary' : 'link'}
disabled={isPending}
label={<LbcMessage test>{displayLabel}</LbcMessage>}
label={<LbcMessage>{displayLabel}</LbcMessage>}
onClick={() => {
claimReward(reward);
}}