eslint fixes
This commit is contained in:
parent
8b75ff0e09
commit
9d6bc66eae
4 changed files with 56 additions and 58 deletions
|
@ -180,7 +180,7 @@ export function CommentCreate(props: Props) {
|
|||
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
|
||||
tipChannelName,
|
||||
}),
|
||||
});
|
||||
|
||||
|
@ -192,7 +192,6 @@ export function CommentCreate(props: Props) {
|
|||
}
|
||||
);
|
||||
} else {
|
||||
|
||||
const sourceClaimId = claim.claim_id;
|
||||
const roundedAmount = Math.round(tipAmount * 100) / 100;
|
||||
|
||||
|
|
|
@ -22,7 +22,6 @@ type Props = {
|
|||
fetchingComments: boolean,
|
||||
doSuperChatList: (string) => void,
|
||||
superChats: Array<Comment>,
|
||||
superChatsReversed: Array,
|
||||
superChatsTotalAmount: number,
|
||||
superChatsFiatAmount: number,
|
||||
myChannels: ?Array<ChannelClaim>,
|
||||
|
@ -48,7 +47,7 @@ export default function LivestreamComments(props: Props) {
|
|||
superChats, // superchats organized by tip amount
|
||||
} = props;
|
||||
|
||||
let { superChatsReversed, superChatsFiatAmount, superChatsTotalAmount } = props;
|
||||
let { superChatsFiatAmount, superChatsTotalAmount } = props;
|
||||
|
||||
const commentsRef = React.createRef();
|
||||
const [scrollBottom, setScrollBottom] = React.useState(true);
|
||||
|
@ -61,50 +60,7 @@ export default function LivestreamComments(props: Props) {
|
|||
const discussionElement = document.querySelector('.livestream__comments');
|
||||
const commentElement = document.querySelector('.livestream-comment');
|
||||
|
||||
// sum total amounts for fiat tips and lbc tips
|
||||
if (superChats) {
|
||||
let fiatAmount = 0;
|
||||
let LBCAmount = 0;
|
||||
for (const superChat of superChats) {
|
||||
if (superChat.is_fiat) {
|
||||
fiatAmount = fiatAmount + superChat.support_amount;
|
||||
} else {
|
||||
LBCAmount = LBCAmount + superChat.support_amount;
|
||||
}
|
||||
}
|
||||
|
||||
superChatsFiatAmount = fiatAmount;
|
||||
superChatsTotalAmount = LBCAmount;
|
||||
}
|
||||
|
||||
// array of superchats organized by fiat or not first, then support amount
|
||||
if (superChats) {
|
||||
const clonedSuperchats = JSON.parse(JSON.stringify(superChats));
|
||||
|
||||
// sort by fiat first then by support amount
|
||||
superChatsReversed = clonedSuperchats.sort(function(a,b) {
|
||||
if (a.is_fiat === b.is_fiat) {
|
||||
return b.support_amount - a.support_amount;
|
||||
} else {
|
||||
return (a.is_fiat === b.is_fiat) ? 0 : a.is_fiat ? -1 : 1;
|
||||
}
|
||||
}).reverse();
|
||||
}
|
||||
|
||||
// todo: implement comment_list --mine in SDK so redux can grab with selectCommentIsMine
|
||||
function isMyComment(channelId: string) {
|
||||
if (myChannels != null && channelId != null) {
|
||||
for (let i = 0; i < myChannels.length; i++) {
|
||||
if (myChannels[i].claim_id === channelId) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
React.useEffect(() => {
|
||||
|
||||
if (claimId) {
|
||||
doCommentList(uri, '', 1, 75);
|
||||
doSuperChatList(uri);
|
||||
|
@ -149,6 +105,51 @@ export default function LivestreamComments(props: Props) {
|
|||
}
|
||||
}, [commentsLength, discussionElement, handleScroll, performedInitialScroll, setPerformedInitialScroll]);
|
||||
|
||||
// sum total amounts for fiat tips and lbc tips
|
||||
if (superChats) {
|
||||
let fiatAmount = 0;
|
||||
let LBCAmount = 0;
|
||||
for (const superChat of superChats) {
|
||||
if (superChat.is_fiat) {
|
||||
fiatAmount = fiatAmount + superChat.support_amount;
|
||||
} else {
|
||||
LBCAmount = LBCAmount + superChat.support_amount;
|
||||
}
|
||||
}
|
||||
|
||||
superChatsFiatAmount = fiatAmount;
|
||||
superChatsTotalAmount = LBCAmount;
|
||||
}
|
||||
|
||||
let superChatsReversed;
|
||||
// array of superchats organized by fiat or not first, then support amount
|
||||
if (superChats) {
|
||||
const clonedSuperchats = JSON.parse(JSON.stringify(superChats));
|
||||
|
||||
// sort by fiat first then by support amount
|
||||
superChatsReversed = clonedSuperchats.sort(function(a, b) {
|
||||
// if both are fiat, organize by support
|
||||
if (a.is_fiat === b.is_fiat) {
|
||||
return b.support_amount - a.support_amount;
|
||||
// otherwise, if they are not both fiat, put the fiat transaction first
|
||||
} else {
|
||||
return (a.is_fiat === b.is_fiat) ? 0 : a.is_fiat ? -1 : 1;
|
||||
}
|
||||
}).reverse();
|
||||
}
|
||||
|
||||
// todo: implement comment_list --mine in SDK so redux can grab with selectCommentIsMine
|
||||
function isMyComment(channelId: string) {
|
||||
if (myChannels != null && channelId != null) {
|
||||
for (let i = 0; i < myChannels.length; i++) {
|
||||
if (myChannels[i].claim_id === channelId) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!claim) {
|
||||
return null;
|
||||
}
|
||||
|
@ -175,7 +176,7 @@ export default function LivestreamComments(props: Props) {
|
|||
label={__('Chat')}
|
||||
onClick={function() {
|
||||
setViewMode(VIEW_MODE_CHAT);
|
||||
const livestreamCommentsDiv = document.getElementsByClassName('livestream__comments')[0]
|
||||
const livestreamCommentsDiv = document.getElementsByClassName('livestream__comments')[0];
|
||||
const divHeight = livestreamCommentsDiv.scrollHeight;
|
||||
livestreamCommentsDiv.scrollTop = divHeight;
|
||||
}}
|
||||
|
@ -189,12 +190,12 @@ export default function LivestreamComments(props: Props) {
|
|||
label={
|
||||
<>
|
||||
<CreditAmount amount={superChatsTotalAmount} size={8} /> /
|
||||
<CreditAmount amount={superChatsFiatAmount} size={8} isFiat={true} /> {' '}{__('Tipped')}
|
||||
<CreditAmount amount={superChatsFiatAmount} size={8} isFiat /> {' '}{__('Tipped')}
|
||||
</>
|
||||
}
|
||||
onClick={function() {
|
||||
setViewMode(VIEW_MODE_SUPER_CHAT);
|
||||
const livestreamCommentsDiv = document.getElementsByClassName('livestream__comments')[0]
|
||||
const livestreamCommentsDiv = document.getElementsByClassName('livestream__comments')[0];
|
||||
const divHeight = livestreamCommentsDiv.scrollHeight;
|
||||
livestreamCommentsDiv.scrollTop = divHeight * -1;
|
||||
}}
|
||||
|
|
|
@ -317,10 +317,9 @@ function WalletSendTip(props: Props) {
|
|||
var text = value.toString();
|
||||
var index = text.indexOf('.');
|
||||
return (text.length - index - 1);
|
||||
}
|
||||
};
|
||||
|
||||
function handleCustomPriceChange(event: SyntheticInputEvent<*>) {
|
||||
|
||||
let tipAmountAsString = event.target.value;
|
||||
|
||||
let tipAmount = parseFloat(tipAmountAsString);
|
||||
|
@ -329,7 +328,6 @@ function WalletSendTip(props: Props) {
|
|||
|
||||
// allow maximum two decimals
|
||||
if (activeTab === TAB_FIAT) {
|
||||
|
||||
if (Number.isNaN(tipAmount)) {
|
||||
setCustomTipAmount('');
|
||||
}
|
||||
|
@ -350,9 +348,9 @@ function WalletSendTip(props: Props) {
|
|||
}
|
||||
} else {
|
||||
if (howManyDecimals > 9) {
|
||||
tipAmount = Number(tipAmount.toString().match(/^-?\d+(?:\.\d{0,8})?/)[0]);
|
||||
tipAmount = Number(tipAmount.toString().match(/^-?\d+(?:\.\d{0,8})?/)[0]);
|
||||
|
||||
setTipError('Please only use up to 8 decimals')
|
||||
setTipError('Please only use up to 8 decimals');
|
||||
}
|
||||
setCustomTipAmount(tipAmount);
|
||||
}
|
||||
|
@ -370,7 +368,7 @@ function WalletSendTip(props: Props) {
|
|||
return false;
|
||||
}
|
||||
|
||||
function convertToTwoDecimals(number){
|
||||
function convertToTwoDecimals(number) {
|
||||
return (Math.round(number * 100) / 100).toFixed(2);
|
||||
}
|
||||
|
||||
|
@ -407,7 +405,7 @@ function WalletSendTip(props: Props) {
|
|||
return (
|
||||
<Form onSubmit={handleSubmit}>
|
||||
{/* if there is no LBC balance, show user frontend to get credits */}
|
||||
{1 == 2 ? (
|
||||
{1 === 2 ? (
|
||||
<Card
|
||||
title={<I18nMessage tokens={{ lbc: <LbcSymbol size={22} /> }}>Supporting content requires %lbc%</I18nMessage>}
|
||||
subtitle={
|
||||
|
|
|
@ -32,6 +32,7 @@ type Props = {
|
|||
source: string,
|
||||
user: User,
|
||||
doOpenModal: (string, {}) => void,
|
||||
doToast: ({ message: string }) => void,
|
||||
};
|
||||
|
||||
type State = {
|
||||
|
@ -174,7 +175,6 @@ class StripeAccountConnection extends React.Component<Props, State> {
|
|||
// not an error from Beamer, throw it
|
||||
throw new Error(error);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue