add toast when someone does a tip for a comment

This commit is contained in:
Anthony 2021-07-25 23:17:44 +02:00
parent 7257d1a884
commit 6105185534
No known key found for this signature in database
GPG key ID: C386D3C93D50E356

View file

@ -131,6 +131,7 @@ export function CommentCreate(props: Props) {
return; return;
} }
// if comment post didn't work, but tip was already made, try againt o create comment
if (commentFailure && tipAmount === successTip.tipAmount) { if (commentFailure && tipAmount === successTip.tipAmount) {
handleCreateComment(successTip.txid); handleCreateComment(successTip.txid);
return; return;
@ -147,6 +148,19 @@ export function CommentCreate(props: Props) {
const activeChannelName = activeChannelClaim && activeChannelClaim.name; const activeChannelName = activeChannelClaim && activeChannelClaim.name;
const activeChannelId = activeChannelClaim && activeChannelClaim.claim_id; const activeChannelId = activeChannelClaim && activeChannelClaim.claim_id;
// setup variables for tip API
let channelClaimId, tipChannelName;
// if there is a signing channel it's on a file
if (claim.signing_channel) {
channelClaimId = claim.signing_channel.claim_id;
tipChannelName = claim.signing_channel.name;
// otherwise it's on the channel page
} else {
channelClaimId = claim.claim_id;
tipChannelName = claim.name;
}
console.log(activeChannelClaim); console.log(activeChannelClaim);
setIsSubmitting(true); setIsSubmitting(true);
@ -162,6 +176,14 @@ export function CommentCreate(props: Props) {
setTimeout(() => { setTimeout(() => {
handleCreateComment(txid); handleCreateComment(txid);
}, 1500); }, 1500);
doToast({
message: __("You sent %tipAmount% LBRY Credits as a tip to %tipChannelName%, I'm sure they appreciate it!", {
tipAmount: tipAmount, // force show decimal places
tipChannelName
}),
});
setSuccessTip({ txid, tipAmount }); setSuccessTip({ txid, tipAmount });
}, },
() => { () => {
@ -170,18 +192,6 @@ export function CommentCreate(props: Props) {
} }
); );
} else { } else {
// setup variables for tip API
let channelClaimId, tipChannelName;
// if there is a signing channel it's on a file
if (claim.signing_channel) {
channelClaimId = claim.signing_channel.claim_id;
tipChannelName = claim.signing_channel.name;
// otherwise it's on the channel page
} else {
channelClaimId = claim.claim_id;
tipChannelName = claim.name;
}
const sourceClaimId = claim.claim_id; const sourceClaimId = claim.claim_id;