mirror of
https://github.com/LBRYFoundation/lbry-desktop.git
synced 2025-09-02 10:15:11 +00:00
MinSuper: handle the display of comments below MinSuper
- If minSuper is unmet: - Hide it from the Super Chat list at the header. - Display the comment as usual, but don't embellish it .
This commit is contained in:
parent
9520a15629
commit
fd5693b448
2 changed files with 15 additions and 4 deletions
|
@ -7,6 +7,7 @@ import {
|
||||||
selectIsFetchingComments,
|
selectIsFetchingComments,
|
||||||
makeSelectSuperChatsForUri,
|
makeSelectSuperChatsForUri,
|
||||||
makeSelectSuperChatTotalAmountForUri,
|
makeSelectSuperChatTotalAmountForUri,
|
||||||
|
selectSettingsByChannelId,
|
||||||
} from 'redux/selectors/comments';
|
} from 'redux/selectors/comments';
|
||||||
import LivestreamComments from './view';
|
import LivestreamComments from './view';
|
||||||
|
|
||||||
|
@ -17,6 +18,7 @@ const select = (state, props) => ({
|
||||||
superChats: makeSelectSuperChatsForUri(props.uri)(state),
|
superChats: makeSelectSuperChatsForUri(props.uri)(state),
|
||||||
superChatsTotalAmount: makeSelectSuperChatTotalAmountForUri(props.uri)(state),
|
superChatsTotalAmount: makeSelectSuperChatTotalAmountForUri(props.uri)(state),
|
||||||
myChannels: selectMyChannelClaims(state),
|
myChannels: selectMyChannelClaims(state),
|
||||||
|
settingsByChannelId: selectSettingsByChannelId(state),
|
||||||
});
|
});
|
||||||
|
|
||||||
export default connect(select, {
|
export default connect(select, {
|
||||||
|
|
|
@ -9,6 +9,7 @@ import UriIndicator from 'component/uriIndicator';
|
||||||
import CreditAmount from 'component/common/credit-amount';
|
import CreditAmount from 'component/common/credit-amount';
|
||||||
import ChannelThumbnail from 'component/channelThumbnail';
|
import ChannelThumbnail from 'component/channelThumbnail';
|
||||||
import Tooltip from 'component/common/tooltip';
|
import Tooltip from 'component/common/tooltip';
|
||||||
|
import { getChannelIdFromClaim } from 'util/claim';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
uri: string,
|
uri: string,
|
||||||
|
@ -24,6 +25,7 @@ type Props = {
|
||||||
superChats: Array<Comment>,
|
superChats: Array<Comment>,
|
||||||
superChatsTotalAmount: number,
|
superChatsTotalAmount: number,
|
||||||
myChannels: ?Array<ChannelClaim>,
|
myChannels: ?Array<ChannelClaim>,
|
||||||
|
settingsByChannelId: { [channelId: string]: PerChannelSettings },
|
||||||
};
|
};
|
||||||
|
|
||||||
const VIEW_MODE_CHAT = 'view_chat';
|
const VIEW_MODE_CHAT = 'view_chat';
|
||||||
|
@ -45,15 +47,22 @@ export default function LivestreamComments(props: Props) {
|
||||||
superChats,
|
superChats,
|
||||||
superChatsTotalAmount,
|
superChatsTotalAmount,
|
||||||
myChannels,
|
myChannels,
|
||||||
|
settingsByChannelId,
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
|
const channelId = getChannelIdFromClaim(claim);
|
||||||
|
const channelSettings = channelId ? settingsByChannelId[channelId] : undefined;
|
||||||
|
const minSuper = (channelSettings && channelSettings.min_tip_amount_super_chat) || 0;
|
||||||
|
|
||||||
|
const superChatFiltered = superChats ? superChats.filter((x) => x.support_amount >= minSuper) : [];
|
||||||
|
|
||||||
const commentsRef = React.createRef();
|
const commentsRef = React.createRef();
|
||||||
const [scrollBottom, setScrollBottom] = React.useState(true);
|
const [scrollBottom, setScrollBottom] = React.useState(true);
|
||||||
const [viewMode, setViewMode] = React.useState(VIEW_MODE_CHAT);
|
const [viewMode, setViewMode] = React.useState(VIEW_MODE_CHAT);
|
||||||
const [performedInitialScroll, setPerformedInitialScroll] = React.useState(false);
|
const [performedInitialScroll, setPerformedInitialScroll] = React.useState(false);
|
||||||
const claimId = claim && claim.claim_id;
|
const claimId = claim && claim.claim_id;
|
||||||
const commentsLength = comments && comments.length;
|
const commentsLength = comments && comments.length;
|
||||||
const commentsToDisplay = viewMode === VIEW_MODE_CHAT ? comments : superChats;
|
const commentsToDisplay = viewMode === VIEW_MODE_CHAT ? comments : superChatFiltered;
|
||||||
|
|
||||||
const discussionElement = document.querySelector('.livestream__comments');
|
const discussionElement = document.querySelector('.livestream__comments');
|
||||||
const commentElement = document.querySelector('.livestream-comment');
|
const commentElement = document.querySelector('.livestream-comment');
|
||||||
|
@ -161,10 +170,10 @@ export default function LivestreamComments(props: Props) {
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
<div ref={commentsRef} className="livestream__comments-wrapper">
|
<div ref={commentsRef} className="livestream__comments-wrapper">
|
||||||
{viewMode === VIEW_MODE_CHAT && superChatsTotalAmount > 0 && superChats && (
|
{viewMode === VIEW_MODE_CHAT && superChatsTotalAmount > 0 && superChatFiltered && (
|
||||||
<div className="livestream-superchats__wrapper">
|
<div className="livestream-superchats__wrapper">
|
||||||
<div className="livestream-superchats__inner">
|
<div className="livestream-superchats__inner">
|
||||||
{superChats.map((superChat: Comment) => (
|
{superChatFiltered.map((superChat: Comment) => (
|
||||||
<Tooltip key={superChat.comment_id} label={superChat.comment}>
|
<Tooltip key={superChat.comment_id} label={superChat.comment}>
|
||||||
<div className="livestream-superchat">
|
<div className="livestream-superchat">
|
||||||
<div className="livestream-superchat__thumbnail">
|
<div className="livestream-superchat__thumbnail">
|
||||||
|
@ -196,7 +205,7 @@ export default function LivestreamComments(props: Props) {
|
||||||
authorUri={comment.channel_url}
|
authorUri={comment.channel_url}
|
||||||
commentId={comment.comment_id}
|
commentId={comment.comment_id}
|
||||||
message={comment.comment}
|
message={comment.comment}
|
||||||
supportAmount={comment.support_amount}
|
supportAmount={comment.support_amount >= minSuper ? comment.support_amount : 0}
|
||||||
isFiat={comment.is_fiat}
|
isFiat={comment.is_fiat}
|
||||||
commentIsMine={comment.channel_id && isMyComment(comment.channel_id)}
|
commentIsMine={comment.channel_id && isMyComment(comment.channel_id)}
|
||||||
/>
|
/>
|
||||||
|
|
Loading…
Add table
Reference in a new issue