Compare commits

...

1 commit

Author SHA1 Message Date
infinite-persistence
e5512b016f
Lint, autoformat -- no functional change.
Doing this now so that an upcoming PR that uses this file won't include these bunch of annoying auto-formatter changes in the diff.
2021-08-13 09:49:47 +08:00

View file

@ -133,15 +133,17 @@ export default function LivestreamComments(props: Props) {
const clonedSuperchats = JSON.parse(JSON.stringify(superChatsByTipAmount)); const clonedSuperchats = JSON.parse(JSON.stringify(superChatsByTipAmount));
// sort by fiat first then by support amount // sort by fiat first then by support amount
superChatsReversed = clonedSuperchats.sort(function(a, b) { superChatsReversed = clonedSuperchats
.sort((a, b) => {
// if both are fiat, organize by support // if both are fiat, organize by support
if (a.is_fiat === b.is_fiat) { if (a.is_fiat === b.is_fiat) {
return b.support_amount - a.support_amount; return b.support_amount - a.support_amount;
// otherwise, if they are not both fiat, put the fiat transaction first // otherwise, if they are not both fiat, put the fiat transaction first
} else { } else {
return (a.is_fiat === b.is_fiat) ? 0 : a.is_fiat ? -1 : 1; return a.is_fiat === b.is_fiat ? 0 : a.is_fiat ? -1 : 1;
} }
}).reverse(); })
.reverse();
} }
// todo: implement comment_list --mine in SDK so redux can grab with selectCommentIsMine // todo: implement comment_list --mine in SDK so redux can grab with selectCommentIsMine
@ -173,14 +175,13 @@ export default function LivestreamComments(props: Props) {
<div className="livestream-discussion__title">{__('Live discussion')}</div> <div className="livestream-discussion__title">{__('Live discussion')}</div>
{(superChatsTotalAmount || 0) > 0 && ( {(superChatsTotalAmount || 0) > 0 && (
<div className="recommended-content__toggles"> <div className="recommended-content__toggles">
{/* the superchats in chronological order button */} {/* the superchats in chronological order button */}
<Button <Button
className={classnames('button-toggle', { className={classnames('button-toggle', {
'button-toggle--active': viewMode === VIEW_MODE_CHAT, 'button-toggle--active': viewMode === VIEW_MODE_CHAT,
})} })}
label={__('Chat')} label={__('Chat')}
onClick={function() { onClick={() => {
setViewMode(VIEW_MODE_CHAT); setViewMode(VIEW_MODE_CHAT);
const livestreamCommentsDiv = document.getElementsByClassName('livestream__comments')[0]; const livestreamCommentsDiv = document.getElementsByClassName('livestream__comments')[0];
const divHeight = livestreamCommentsDiv.scrollHeight; const divHeight = livestreamCommentsDiv.scrollHeight;
@ -196,10 +197,10 @@ export default function LivestreamComments(props: Props) {
label={ label={
<> <>
<CreditAmount amount={superChatsTotalAmount || 0} size={8} /> / <CreditAmount amount={superChatsTotalAmount || 0} size={8} /> /
<CreditAmount amount={superChatsFiatAmount || 0} size={8} isFiat /> {' '}{__('Tipped')} <CreditAmount amount={superChatsFiatAmount || 0} size={8} isFiat /> {__('Tipped')}
</> </>
} }
onClick={function() { onClick={() => {
setViewMode(VIEW_MODE_SUPER_CHAT); setViewMode(VIEW_MODE_SUPER_CHAT);
const livestreamCommentsDiv = document.getElementsByClassName('livestream__comments')[0]; const livestreamCommentsDiv = document.getElementsByClassName('livestream__comments')[0];
const divHeight = livestreamCommentsDiv.scrollHeight; const divHeight = livestreamCommentsDiv.scrollHeight;
@ -261,7 +262,8 @@ export default function LivestreamComments(props: Props) {
{/* top to bottom comment display */} {/* top to bottom comment display */}
{!fetchingComments && commentsByChronologicalOrder.length > 0 ? ( {!fetchingComments && commentsByChronologicalOrder.length > 0 ? (
<div className="livestream__comments"> <div className="livestream__comments">
{viewMode === VIEW_MODE_CHAT && commentsToDisplay.map((comment) => ( {viewMode === VIEW_MODE_CHAT &&
commentsToDisplay.map((comment) => (
<LivestreamComment <LivestreamComment
key={comment.comment_id} key={comment.comment_id}
uri={uri} uri={uri}
@ -274,7 +276,9 @@ export default function LivestreamComments(props: Props) {
/> />
))} ))}
{viewMode === VIEW_MODE_SUPER_CHAT && superChatsReversed && superChatsReversed.map((comment) => ( {viewMode === VIEW_MODE_SUPER_CHAT &&
superChatsReversed &&
superChatsReversed.map((comment) => (
<LivestreamComment <LivestreamComment
key={comment.comment_id} key={comment.comment_id}
uri={uri} uri={uri}