Stripe integration fix #6850
4 changed files with 19 additions and 19 deletions
|
@ -37,12 +37,12 @@ export default function LivestreamComments(props: Props) {
|
|||
embed,
|
||||
doCommentSocketConnect,
|
||||
|
||||
doCommentSocketDisconnect,
|
||||
comments, // comments in chronological order (oldest first)
|
||||
comments: commentsByChronologicalOrder,
|
||||
doCommentList,
|
||||
fetchingComments,
|
||||
doSuperChatList,
|
||||
myChannels,
|
||||
superChats, // superchats organized by tip amount
|
||||
superChats: superChatsByTipAmount,
|
||||
} = props;
|
||||
|
||||
let superChatsFiatAmount, superChatsTotalAmount;
|
||||
|
@ -52,8 +52,8 @@ export default function LivestreamComments(props: Props) {
|
|||
const [viewMode, setViewMode] = React.useState(VIEW_MODE_CHAT);
|
||||
const [performedInitialScroll, setPerformedInitialScroll] = React.useState(false);
|
||||
const claimId = claim && claim.claim_id;
|
||||
const commentsLength = comments && comments.length;
|
||||
const commentsToDisplay = viewMode === VIEW_MODE_CHAT ? comments : superChats;
|
||||
const commentsLength = commentsByChronologicalOrder && commentsByChronologicalOrder.length;
|
||||
const commentsToDisplay = viewMode === VIEW_MODE_CHAT ? commentsByChronologicalOrder : superChatsByTipAmount;
|
||||
|
||||
const discussionElement = document.querySelector('.livestream__comments');
|
||||
const commentElement = document.querySelector('.livestream-comment');
|
||||
|
@ -104,10 +104,10 @@ export default function LivestreamComments(props: Props) {
|
|||
}, [commentsLength, discussionElement, handleScroll, performedInitialScroll, setPerformedInitialScroll]);
|
||||
|
||||
// sum total amounts for fiat tips and lbc tips
|
||||
if (superChats) {
|
||||
if (superChatsByTipAmount) {
|
||||
let fiatAmount = 0;
|
||||
let LBCAmount = 0;
|
||||
for (const superChat of superChats) {
|
||||
for (const superChat of superChatsByTipAmount) {
|
||||
if (superChat.is_fiat) {
|
||||
fiatAmount = fiatAmount + superChat.support_amount;
|
||||
} else {
|
||||
|
@ -121,8 +121,8 @@ export default function LivestreamComments(props: Props) {
|
|||
|
||||
let superChatsReversed;
|
||||
// array of superchats organized by fiat or not first, then support amount
|
||||
if (superChats) {
|
||||
const clonedSuperchats = JSON.parse(JSON.stringify(superChats));
|
||||
if (superChatsByTipAmount) {
|
||||
const clonedSuperchats = JSON.parse(JSON.stringify(superChatsByTipAmount));
|
||||
|
||||
// sort by fiat first then by support amount
|
||||
superChatsReversed = clonedSuperchats.sort(function(a, b) {
|
||||
|
@ -202,16 +202,16 @@ export default function LivestreamComments(props: Props) {
|
|||
)}
|
||||
</div>
|
||||
<>
|
||||
{fetchingComments && !comments && (
|
||||
{fetchingComments && !commentsByChronologicalOrder && (
|
||||
<div className="main--empty">
|
||||
<Spinner />
|
||||
</div>
|
||||
)}
|
||||
<div ref={commentsRef} className="livestream__comments-wrapper">
|
||||
{viewMode === VIEW_MODE_CHAT && superChatsTotalAmount > 0 && superChats && (
|
||||
{viewMode === VIEW_MODE_CHAT && superChatsTotalAmount > 0 && superChatsByTipAmount && (
|
||||
<div className="livestream-superchats__wrapper">
|
||||
<div className="livestream-superchats__inner">
|
||||
{superChats.map((superChat: Comment) => (
|
||||
{superChatsByTipAmount.map((superChat: Comment) => (
|
||||
<Tooltip key={superChat.comment_id} label={superChat.comment}>
|
||||
<div className="livestream-superchat">
|
||||
<div className="livestream-superchat__thumbnail">
|
||||
|
@ -235,7 +235,7 @@ export default function LivestreamComments(props: Props) {
|
|||
)}
|
||||
|
||||
{/* top to bottom comment display */}
|
||||
{!fetchingComments && comments.length > 0 ? (
|
||||
{!fetchingComments && commentsByChronologicalOrder.length > 0 ? (
|
||||
<div className="livestream__comments">
|
||||
{viewMode === VIEW_MODE_CHAT && commentsToDisplay.map((comment) => (
|
||||
<LivestreamComment
|
||||
|
|
|
@ -621,7 +621,7 @@ function WalletSendTip(props: Props) {
|
|||
)}
|
||||
</>
|
||||
// if it's LBC and there is no balance, you can prompt to purchase LBC
|
||||
: <>
|
||||
:
|
||||
<Card
|
||||
title={<I18nMessage tokens={{ lbc: <LbcSymbol size={22} /> }}>Supporting content requires %lbc%</I18nMessage>}
|
||||
subtitle={
|
||||
|
@ -642,7 +642,7 @@ function WalletSendTip(props: Props) {
|
|||
<Button button="link" label={__('Nevermind')} onClick={closeModal} />
|
||||
</div>
|
||||
}
|
||||
/></>
|
||||
/>
|
||||
)
|
||||
}
|
||||
/>
|
||||
|
|
|
@ -4,7 +4,6 @@ import StripeAccountConnection from './view';
|
|||
import { selectUser } from 'redux/selectors/user';
|
||||
import { doToast } from 'redux/actions/notifications';
|
||||
|
||||
// function that receives state parameter and returns object of functions that accept state
|
||||
const select = (state) => ({
|
||||
user: selectUser(state),
|
||||
});
|
||||
|
|
|
@ -19,6 +19,9 @@ if (STRIPE_PUBLIC_KEY.indexOf('pk_live') > -1) {
|
|||
stripeEnvironment = 'live';
|
||||
}
|
||||
|
||||
const APIS_DOWN_ERROR_RESPONSE = 'There was an error from the server, please let support know';
|
||||
const CARD_SETUP_ERROR_RESPONSE = 'There was an error getting your card setup, please let support know';
|
||||
|
||||
// eslint-disable-next-line flowtype/no-types-missing-file-annotation
|
||||
type Props = {
|
||||
disabled: boolean,
|
||||
|
@ -188,12 +191,10 @@ class SettingsStripeCard extends React.Component<Props, State> {
|
|||
});
|
||||
// 500 error from the backend being down
|
||||
} else if (error === 'internal_apis_down') {
|
||||
const displayString = 'There was an error from the server, please let support know';
|
||||
doToast({ message: displayString, isError: true });
|
||||
doToast({ message: APIS_DOWN_ERROR_RESPONSE, isError: true });
|
||||
} else {
|
||||
// probably an error from stripe
|
||||
const displayString = 'There was an error getting your card setup, please let support know';
|
||||
doToast({ message: displayString, isError: true });
|
||||
doToast({ message: CARD_SETUP_ERROR_RESPONSE, isError: true });
|
||||
}
|
||||
});
|
||||
}, 250);
|
||||
|
|
Loading…
Reference in a new issue
Can we use better variable names rather than comments in cases like these?
destructure props with const. we usually don't mutate passed props.
is it even in props?