From 381200800e3663957981a352f961a2ec0f99b2e3 Mon Sep 17 00:00:00 2001
From: saltrafael <76502841+saltrafael@users.noreply.github.com>
Date: Tue, 15 Feb 2022 16:28:06 -0300
Subject: [PATCH] Revert tips by amount on hyper chat banner (#877)
---
ui/component/livestreamChatLayout/view.jsx | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/ui/component/livestreamChatLayout/view.jsx b/ui/component/livestreamChatLayout/view.jsx
index 15f02f2f8..c7dcfd92d 100644
--- a/ui/component/livestreamChatLayout/view.jsx
+++ b/ui/component/livestreamChatLayout/view.jsx
@@ -83,8 +83,12 @@ export default function LivestreamChatLayout(props: Props) {
const [superchatsAmount, setSuperchatsAmount] = React.useState(false);
const [chatElement, setChatElement] = React.useState();
- const superChatsByChronologicalOrder =
- superChatsByAmount && superChatsByAmount.sort((a, b) => b.timestamp - a.timestamp);
+ let superChatsByChronologicalOrder = [];
+ if (superChatsByAmount) superChatsByAmount.forEach((chat) => superChatsByChronologicalOrder.push(chat));
+ if (superChatsByChronologicalOrder.length > 0) {
+ superChatsByChronologicalOrder.sort((a, b) => b.timestamp - a.timestamp);
+ }
+
const commentsToDisplay =
viewMode === VIEW_MODES.CHAT ? commentsByChronologicalOrder : superChatsByChronologicalOrder;
const commentsLength = commentsToDisplay && commentsToDisplay.length;
@@ -291,13 +295,13 @@ export default function LivestreamChatLayout(props: Props) {
'livestream-comments__top-actions--mobile': isMobile,
})}
>
- {isMobile && ((pinnedComment && showPinned) || (superChatsByChronologicalOrder && !superchatsHidden)) && (
+ {isMobile && ((pinnedComment && showPinned) || (superChatsByAmount && !superchatsHidden)) && (
)}
- {viewMode === VIEW_MODES.CHAT && superChatsByChronologicalOrder && (
+ {viewMode === VIEW_MODES.CHAT && superChatsByAmount && (