Handle comment + tip failure, don't re-support
This commit is contained in:
parent
141ebcf1cd
commit
7483429ee6
1 changed files with 13 additions and 1 deletions
|
@ -62,6 +62,8 @@ export function CommentCreate(props: Props) {
|
||||||
location: { pathname },
|
location: { pathname },
|
||||||
} = useHistory();
|
} = useHistory();
|
||||||
const [isSubmitting, setIsSubmitting] = React.useState(false);
|
const [isSubmitting, setIsSubmitting] = React.useState(false);
|
||||||
|
const [commentFailure, setCommentFailure] = React.useState(false);
|
||||||
|
const [successTip, setSuccessTip] = React.useState({ txid: undefined, tipAmount: undefined });
|
||||||
const { claim_id: claimId } = claim;
|
const { claim_id: claimId } = claim;
|
||||||
const [isSupportComment, setIsSupportComment] = React.useState();
|
const [isSupportComment, setIsSupportComment] = React.useState();
|
||||||
const [isReviewingSupportComment, setIsReviewingSupportComment] = React.useState();
|
const [isReviewingSupportComment, setIsReviewingSupportComment] = React.useState();
|
||||||
|
@ -120,6 +122,13 @@ export function CommentCreate(props: Props) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (commentFailure && tipAmount === successTip.tipAmount) {
|
||||||
|
handleCreateComment(successTip.txid);
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
setSuccessTip({ txid: undefined, tipAmount: undefined });
|
||||||
|
}
|
||||||
|
|
||||||
const params = {
|
const params = {
|
||||||
amount: tipAmount,
|
amount: tipAmount,
|
||||||
claim_id: claimId,
|
claim_id: claimId,
|
||||||
|
@ -135,6 +144,7 @@ export function CommentCreate(props: Props) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
handleCreateComment(txid);
|
handleCreateComment(txid);
|
||||||
}, 1500);
|
}, 1500);
|
||||||
|
setSuccessTip({ txid, tipAmount });
|
||||||
},
|
},
|
||||||
() => {
|
() => {
|
||||||
setIsSubmitting(false);
|
setIsSubmitting(false);
|
||||||
|
@ -153,6 +163,7 @@ export function CommentCreate(props: Props) {
|
||||||
setLastCommentTime(Date.now());
|
setLastCommentTime(Date.now());
|
||||||
setIsReviewingSupportComment(false);
|
setIsReviewingSupportComment(false);
|
||||||
setIsSupportComment(false);
|
setIsSupportComment(false);
|
||||||
|
setCommentFailure(false);
|
||||||
justCommented.push(res.comment_id);
|
justCommented.push(res.comment_id);
|
||||||
|
|
||||||
if (onDoneReplying) {
|
if (onDoneReplying) {
|
||||||
|
@ -162,6 +173,7 @@ export function CommentCreate(props: Props) {
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
setIsSubmitting(false);
|
setIsSubmitting(false);
|
||||||
|
setCommentFailure(true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -212,7 +224,7 @@ export function CommentCreate(props: Props) {
|
||||||
autoFocus
|
autoFocus
|
||||||
button="primary"
|
button="primary"
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
label={isSubmitting ? __('Sending...') : __('Send')}
|
label={isSubmitting ? __('Sending...') : (commentFailure && tipAmount === successTip.tipAmount) ? __('Re-submit') : __('Send')}
|
||||||
onClick={handleSupportComment}
|
onClick={handleSupportComment}
|
||||||
/>
|
/>
|
||||||
<Button button="link" label={__('Cancel')} onClick={() => setIsReviewingSupportComment(false)} />
|
<Button button="link" label={__('Cancel')} onClick={() => setIsReviewingSupportComment(false)} />
|
||||||
|
|
Loading…
Add table
Reference in a new issue