diff --git a/ui/component/livestreamComments/view.jsx b/ui/component/livestreamComments/view.jsx index f4b073fef..43cd71bfc 100644 --- a/ui/component/livestreamComments/view.jsx +++ b/ui/component/livestreamComments/view.jsx @@ -22,6 +22,7 @@ type Props = { fetchingComments: boolean, doSuperChatList: (string) => void, superChats: Array, + superChatsReversed: Array, superChatsTotalAmount: number, myChannels: ?Array, }; @@ -38,15 +39,30 @@ export default function LivestreamComments(props: Props) { embed, doCommentSocketConnect, doCommentSocketDisconnect, - comments, + comments, // superchats in chronological format doCommentList, fetchingComments, doSuperChatList, - superChats, superChatsTotalAmount, myChannels, + superChats, // superchats organized by tip amount } = props; + let { superChatsReversed } = props; + + 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(); + } + const commentsRef = React.createRef(); const [scrollBottom, setScrollBottom] = React.useState(true); const [viewMode, setViewMode] = React.useState(VIEW_MODE_CHAT); @@ -71,6 +87,7 @@ export default function LivestreamComments(props: Props) { } React.useEffect(() => { + if (claimId) { doCommentList(uri, '', 1, 75); doSuperChatList(uri); @@ -132,6 +149,8 @@ export default function LivestreamComments(props: Props) {
{__('Live discussion')}
{superChatsTotalAmount > 0 && (
+ + {/* the superchats in chronological order button */}
)} + {/* top to bottom comment display */} {!fetchingComments && comments.length > 0 ? (
- {commentsToDisplay.map((comment) => ( + {viewMode === VIEW_MODE_CHAT && commentsToDisplay.map((comment) => ( ))} + + {viewMode === VIEW_MODE_SUPER_CHAT && superChatsReversed && superChatsReversed.map((comment) => ( + + ))} +
) : (