Lint and cleanup. No functional change.

This commit is contained in:
infinite-persistence 2021-07-29 21:07:23 +08:00
parent 4ff32e0c61
commit 7537b5ae7b
No known key found for this signature in database
GPG key ID: B9C3252EDC3D0AA0
2 changed files with 15 additions and 22 deletions

View file

@ -72,8 +72,7 @@ export function CommentCreate(props: Props) {
sendTip, sendTip,
doToast, doToast,
} = props; } = props;
const buttonref: ElementRef<any> = React.useRef(); const buttonRef: ElementRef<any> = React.useRef();
const { const {
push, push,
location: { pathname }, location: { pathname },
@ -89,11 +88,8 @@ export function CommentCreate(props: Props) {
const [advancedEditor, setAdvancedEditor] = usePersistedState('comment-editor-mode', false); const [advancedEditor, setAdvancedEditor] = usePersistedState('comment-editor-mode', false);
const hasChannels = channels && channels.length; const hasChannels = channels && channels.length;
const charCount = commentValue.length; const charCount = commentValue.length;
const [activeTab, setActiveTab] = React.useState(''); const [activeTab, setActiveTab] = React.useState('');
const [tipError, setTipError] = React.useState(); const [tipError, setTipError] = React.useState();
const disabled = isSubmitting || !activeChannelClaim || !commentValue.length; const disabled = isSubmitting || !activeChannelClaim || !commentValue.length;
const [shouldDisableReviewButton, setShouldDisableReviewButton] = React.useState(); const [shouldDisableReviewButton, setShouldDisableReviewButton] = React.useState();
@ -112,7 +108,7 @@ export function CommentCreate(props: Props) {
const KEYCODE_ENTER = 13; const KEYCODE_ENTER = 13;
if ((livestream || e.ctrlKey || e.metaKey) && e.keyCode === KEYCODE_ENTER) { if ((livestream || e.ctrlKey || e.metaKey) && e.keyCode === KEYCODE_ENTER) {
e.preventDefault(); e.preventDefault();
buttonref.current.click(); buttonRef.current.click();
} }
} }
@ -186,8 +182,7 @@ export function CommentCreate(props: Props) {
} }
const sourceClaimId = claim.claim_id; const sourceClaimId = claim.claim_id;
const roundedAmount = Math.round(tipAmount * 100) / 100;
var roundedAmount = Math.round(tipAmount * 100) / 100;
Lbryio.call( Lbryio.call(
'customer', 'customer',
@ -206,8 +201,6 @@ export function CommentCreate(props: Props) {
'post' 'post'
) )
.then((customerTipResponse) => { .then((customerTipResponse) => {
console.log(customerTipResponse);
const paymentIntendId = customerTipResponse.payment_intent_id; const paymentIntendId = customerTipResponse.payment_intent_id;
handleCreateComment(null, paymentIntendId, stripeEnvironment); handleCreateComment(null, paymentIntendId, stripeEnvironment);
@ -227,14 +220,14 @@ export function CommentCreate(props: Props) {
// handleCreateComment(null); // handleCreateComment(null);
}) })
.catch(function (error) { .catch((error) => {
var displayError = 'Sorry, there was an error in processing your payment!'; doToast({
message:
if (error.message !== 'payment intent failed to confirm') { error.message !== 'payment intent failed to confirm'
displayError = error.message; ? error.message
} : 'Sorry, there was an error in processing your payment!',
isError: true,
doToast({ message: displayError, isError: true }); });
}); });
} }
} }
@ -263,7 +256,7 @@ export function CommentCreate(props: Props) {
} }
} }
}) })
.catch((e) => { .catch(() => {
setIsSubmitting(false); setIsSubmitting(false);
setCommentFailure(true); setCommentFailure(true);
}); });
@ -313,7 +306,7 @@ export function CommentCreate(props: Props) {
<div className="comment__create"> <div className="comment__create">
<div className="comment__sc-preview"> <div className="comment__sc-preview">
<CreditAmount <CreditAmount
className="comment__scpreview-amount" className="comment__sc-preview-amount"
isFiat={activeTab === TAB_FIAT} isFiat={activeTab === TAB_FIAT}
amount={tipAmount} amount={tipAmount}
size={activeTab === TAB_LBC ? 18 : 2} size={activeTab === TAB_LBC ? 18 : 2}
@ -406,7 +399,7 @@ export function CommentCreate(props: Props) {
) : ( ) : (
<> <>
<Button <Button
ref={buttonref} ref={buttonRef}
button="primary" button="primary"
disabled={disabled} disabled={disabled}
type="submit" type="submit"

View file

@ -127,7 +127,7 @@ $thumbnailWidthSmall: 1rem;
margin-top: var(--spacing-xxs); margin-top: var(--spacing-xxs);
} }
.comment__scpreview-amount { .comment__sc-preview-amount {
margin-right: var(--spacing-m); margin-right: var(--spacing-m);
font-size: var(--font-large); font-size: var(--font-large);
} }