Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
54f5c1f0f1 |
No files matched your search
@@ -2145,11 +2145,8 @@
|
||||
"%title% by %channelTitle%": "%title% by %channelTitle%",
|
||||
"%title% by %channelTitle% %ariaDate%": "%title% by %channelTitle% %ariaDate%",
|
||||
"%title% by %channelTitle% %ariaDate%, %mediaDuration%": "%title% by %channelTitle% %ariaDate%, %mediaDuration%",
|
||||
"Collapse Thread": "Collapse Thread",
|
||||
"Collapse": "Collapse",
|
||||
"Expand Comments": "Expand Comments",
|
||||
"Expand": "Expand",
|
||||
"Load More": "Load More",
|
||||
"%formattedSubCount% Followers": "%formattedSubCount% Followers",
|
||||
"1 Follower": "1 Follower",
|
||||
"Collection": "Collection",
|
||||
@@ -2183,5 +2180,13 @@
|
||||
"Creator": "Creator",
|
||||
"From comments": "From comments",
|
||||
"From search": "From search",
|
||||
"Manage tags": "Manage tags",
|
||||
"Enter the full channel name or URL to search.\n\nExamples:\n - @channel\n - @channel#3\n - https://odysee.com/@Odysee:8\n - lbry://@Odysee#8": "Enter the full channel name or URL to search.\n\nExamples:\n - @channel\n - @channel#3\n - https://odysee.com/@Odysee:8\n - lbry://@Odysee#8",
|
||||
"Trending for #Btc": "Trending for #Btc",
|
||||
"Block and muted channels": "Block and muted channels",
|
||||
"Claiming credits...": "Claiming credits...",
|
||||
"Strict": "Strict",
|
||||
"MatchCount": "MatchCount",
|
||||
"Word Count": "Word Count",
|
||||
"--end--": "--end--"
|
||||
}
|
||||
@@ -17,7 +17,7 @@ function ChannelDiscussion(props: Props) {
|
||||
}
|
||||
return (
|
||||
<section className="section">
|
||||
<CommentsList uri={uri} linkedCommentId={linkedCommentId} />
|
||||
<CommentsList uri={uri} linkedCommentId={linkedCommentId} commentsAreExpanded />
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -53,6 +53,7 @@ type Props = {
|
||||
streamType?: string | Array<string>,
|
||||
defaultStreamType?: string | Array<string>,
|
||||
|
||||
searchText?: string,
|
||||
empty?: string,
|
||||
feeAmount?: string,
|
||||
releaseTime?: string,
|
||||
@@ -122,6 +123,7 @@ function ClaimListDiscover(props: Props) {
|
||||
name,
|
||||
claimType,
|
||||
pageSize,
|
||||
searchText,
|
||||
defaultClaimType,
|
||||
streamType = SIMPLE_SITE ? [CS.FILE_VIDEO, CS.FILE_AUDIO] : undefined,
|
||||
defaultStreamType = SIMPLE_SITE ? CS.FILE_VIDEO : undefined, // add param for DEFAULT_STREAM_TYPE
|
||||
@@ -281,6 +283,10 @@ function ClaimListDiscover(props: Props) {
|
||||
options.channel_ids = channelIdsParam;
|
||||
}
|
||||
|
||||
if (searchText) {
|
||||
options.text = searchText;
|
||||
}
|
||||
|
||||
if (tagsParam) {
|
||||
if (tagsParam !== CS.TAGS_ALL && tagsParam !== '') {
|
||||
if (tagsParam === CS.TAGS_FOLLOWED) {
|
||||
|
||||
@@ -19,30 +19,24 @@ import { selectActiveChannelClaim } from 'redux/selectors/app';
|
||||
import { selectPlayingUri } from 'redux/selectors/content';
|
||||
import Comment from './view';
|
||||
|
||||
const makeMapStateToProps = (originalState, originalProps) => {
|
||||
const activeChannelClaim = selectActiveChannelClaim(originalState);
|
||||
const select = (state, props) => {
|
||||
const activeChannelClaim = selectActiveChannelClaim(state);
|
||||
const activeChannelId = activeChannelClaim && activeChannelClaim.claim_id;
|
||||
const reactionKey = activeChannelId ? `${originalProps.commentId}:${activeChannelId}` : originalProps.commentId;
|
||||
const selectOthersReactionsForComment = makeSelectOthersReactionsForComment(reactionKey);
|
||||
const reactionKey = activeChannelId ? `${props.commentId}:${activeChannelId}` : props.commentId;
|
||||
|
||||
const select = (state, props) => {
|
||||
const othersReacts = selectOthersReactionsForComment(state);
|
||||
|
||||
return {
|
||||
claim: makeSelectClaimForUri(props.uri)(state),
|
||||
thumbnail: props.authorUri && makeSelectThumbnailForUri(props.authorUri)(state),
|
||||
channelIsBlocked: props.authorUri && makeSelectChannelIsMuted(props.authorUri)(state),
|
||||
commentingEnabled: IS_WEB ? Boolean(selectUserVerifiedEmail(state)) : true,
|
||||
othersReacts,
|
||||
activeChannelClaim,
|
||||
myChannels: selectMyChannelClaims(state),
|
||||
playingUri: selectPlayingUri(state),
|
||||
stakedLevel: makeSelectStakedLevelForChannelUri(props.authorUri)(state),
|
||||
linkedCommentAncestors: selectLinkedCommentAncestors(state),
|
||||
totalReplyPages: makeSelectTotalReplyPagesForParentId(props.commentId)(state),
|
||||
};
|
||||
return {
|
||||
claim: makeSelectClaimForUri(props.uri)(state),
|
||||
thumbnail: props.authorUri && makeSelectThumbnailForUri(props.authorUri)(state),
|
||||
channelIsBlocked: props.authorUri && makeSelectChannelIsMuted(props.authorUri)(state),
|
||||
commentingEnabled: IS_WEB ? Boolean(selectUserVerifiedEmail(state)) : true,
|
||||
othersReacts: makeSelectOthersReactionsForComment(reactionKey)(state),
|
||||
activeChannelClaim,
|
||||
myChannels: selectMyChannelClaims(state),
|
||||
playingUri: selectPlayingUri(state),
|
||||
stakedLevel: makeSelectStakedLevelForChannelUri(props.authorUri)(state),
|
||||
linkedCommentAncestors: selectLinkedCommentAncestors(state),
|
||||
totalReplyPages: makeSelectTotalReplyPagesForParentId(props.commentId)(state),
|
||||
};
|
||||
return select;
|
||||
};
|
||||
|
||||
const perform = (dispatch) => ({
|
||||
@@ -53,4 +47,4 @@ const perform = (dispatch) => ({
|
||||
doToast: (options) => dispatch(doToast(options)),
|
||||
});
|
||||
|
||||
export default connect(makeMapStateToProps, perform)(Comment);
|
||||
export default connect(select, perform)(Comment);
|
||||
@@ -1,13 +1,13 @@
|
||||
import { connect } from 'react-redux';
|
||||
import { makeSelectChannelPermUrlForClaimUri, makeSelectClaimIsMine, makeSelectClaimForUri } from 'lbry-redux';
|
||||
import { doCommentPin, doCommentModAddDelegate } from 'redux/actions/comments';
|
||||
import { doChannelMute } from 'redux/actions/blocked';
|
||||
// import { doSetActiveChannel } from 'redux/actions/app';
|
||||
import { doCommentPin, doCommentModAddDelegate } from 'redux/actions/comments';
|
||||
import { doOpenModal } from 'redux/actions/app';
|
||||
import { doSetPlayingUri } from 'redux/actions/content';
|
||||
import { doToast } from 'redux/actions/notifications';
|
||||
import { makeSelectChannelPermUrlForClaimUri, makeSelectClaimIsMine, makeSelectClaimForUri } from 'lbry-redux';
|
||||
import { selectActiveChannelClaim } from 'redux/selectors/app';
|
||||
import { selectPlayingUri } from 'redux/selectors/content';
|
||||
import { selectModerationDelegatorsById } from 'redux/selectors/comments';
|
||||
import { selectPlayingUri } from 'redux/selectors/content';
|
||||
import CommentMenuList from './view';
|
||||
|
||||
const select = (state, props) => ({
|
||||
@@ -24,9 +24,9 @@ const perform = (dispatch) => ({
|
||||
clearPlayingUri: () => dispatch(doSetPlayingUri({ uri: null })),
|
||||
muteChannel: (channelUri) => dispatch(doChannelMute(channelUri)),
|
||||
pinComment: (commentId, claimId, remove) => dispatch(doCommentPin(commentId, claimId, remove)),
|
||||
// setActiveChannel: channelId => dispatch(doSetActiveChannel(channelId)),
|
||||
commentModAddDelegate: (modChanId, modChanName, creatorChannelClaim) =>
|
||||
dispatch(doCommentModAddDelegate(modChanId, modChanName, creatorChannelClaim, true)),
|
||||
doToast: (props) => dispatch(doToast(props)),
|
||||
});
|
||||
|
||||
export default connect(select, perform)(CommentMenuList);
|
||||
@@ -1,12 +1,14 @@
|
||||
// @flow
|
||||
import { getChannelFromClaim } from 'util/claim';
|
||||
import { MenuList, MenuItem } from '@reach/menu-button';
|
||||
import { parseURI } from 'lbry-redux';
|
||||
import { URL } from 'config';
|
||||
import { useHistory } from 'react-router';
|
||||
import * as ICONS from 'constants/icons';
|
||||
import * as MODALS from 'constants/modal_types';
|
||||
import React from 'react';
|
||||
import { MenuList, MenuItem } from '@reach/menu-button';
|
||||
import ChannelThumbnail from 'component/channelThumbnail';
|
||||
import Icon from 'component/common/icon';
|
||||
import { parseURI } from 'lbry-redux';
|
||||
import { getChannelFromClaim } from 'util/claim';
|
||||
import React from 'react';
|
||||
|
||||
type Props = {
|
||||
uri: ?string,
|
||||
@@ -18,7 +20,6 @@ type Props = {
|
||||
disableEdit?: boolean,
|
||||
disableRemove?: boolean,
|
||||
supportAmount?: any,
|
||||
handleEditComment: () => void,
|
||||
// --- select ---
|
||||
claim: ?Claim,
|
||||
claimIsMine: boolean,
|
||||
@@ -27,6 +28,8 @@ type Props = {
|
||||
playingUri: ?PlayingUri,
|
||||
moderationDelegatorsById: { [string]: { global: boolean, delegators: { name: string, claimId: string } } },
|
||||
// --- perform ---
|
||||
doToast: ({ message: string }) => void,
|
||||
handleEditComment: () => void,
|
||||
openModal: (id: string, {}) => void,
|
||||
clearPlayingUri: () => void,
|
||||
muteChannel: (string) => void,
|
||||
@@ -42,24 +45,29 @@ function CommentMenuList(props: Props) {
|
||||
authorUri,
|
||||
commentIsMine,
|
||||
commentId,
|
||||
muteChannel,
|
||||
pinComment,
|
||||
clearPlayingUri,
|
||||
activeChannelClaim,
|
||||
contentChannelPermanentUrl,
|
||||
isTopLevel,
|
||||
isPinned,
|
||||
handleEditComment,
|
||||
commentModAddDelegate,
|
||||
playingUri,
|
||||
moderationDelegatorsById,
|
||||
disableEdit,
|
||||
disableRemove,
|
||||
openModal,
|
||||
supportAmount,
|
||||
doToast,
|
||||
handleEditComment,
|
||||
openModal,
|
||||
clearPlayingUri,
|
||||
muteChannel,
|
||||
pinComment,
|
||||
commentModAddDelegate,
|
||||
setQuickReply,
|
||||
} = props;
|
||||
|
||||
const {
|
||||
location: { pathname, search },
|
||||
} = useHistory();
|
||||
|
||||
const contentChannelClaim = getChannelFromClaim(claim);
|
||||
const activeModeratorInfo = activeChannelClaim && moderationDelegatorsById[activeChannelClaim.claim_id];
|
||||
const activeChannelIsCreator = activeChannelClaim && activeChannelClaim.permanent_url === contentChannelPermanentUrl;
|
||||
@@ -70,10 +78,6 @@ function CommentMenuList(props: Props) {
|
||||
activeModeratorInfo &&
|
||||
Object.values(activeModeratorInfo.delegators).includes(contentChannelClaim.claim_id);
|
||||
|
||||
function handlePinComment(commentId, claimId, remove) {
|
||||
pinComment(commentId, claimId, remove);
|
||||
}
|
||||
|
||||
function handleDeleteComment() {
|
||||
if (playingUri && playingUri.source === 'comment') {
|
||||
clearPlayingUri();
|
||||
@@ -87,14 +91,6 @@ function CommentMenuList(props: Props) {
|
||||
});
|
||||
}
|
||||
|
||||
function handleCommentBlock() {
|
||||
openModal(MODALS.BLOCK_CHANNEL, { contentUri: uri, commenterUri: authorUri });
|
||||
}
|
||||
|
||||
function handleCommentMute() {
|
||||
muteChannel(authorUri);
|
||||
}
|
||||
|
||||
function assignAsModerator() {
|
||||
if (activeChannelClaim && authorUri) {
|
||||
const { channelName, channelClaimId } = parseURI(authorUri);
|
||||
@@ -155,6 +151,15 @@ function CommentMenuList(props: Props) {
|
||||
);
|
||||
}
|
||||
|
||||
function handleCopyCommentLink() {
|
||||
const urlParams = new URLSearchParams(search);
|
||||
urlParams.delete('lc');
|
||||
urlParams.append('lc', commentId);
|
||||
navigator.clipboard
|
||||
.writeText(`${URL}${pathname}?${urlParams.toString()}`)
|
||||
.then(() => doToast({ message: __('Link copied.') }));
|
||||
}
|
||||
|
||||
return (
|
||||
<MenuList className="menu__list">
|
||||
{activeChannelIsCreator && <div className="comment__menu-title">{__('Creator tools')}</div>}
|
||||
@@ -162,7 +167,7 @@ function CommentMenuList(props: Props) {
|
||||
{activeChannelIsCreator && isTopLevel && (
|
||||
<MenuItem
|
||||
className="comment__menu-option menu__link"
|
||||
onSelect={() => handlePinComment(commentId, claim ? claim.claim_id : '', isPinned)}
|
||||
onSelect={() => pinComment(commentId, claim ? claim.claim_id : '', isPinned)}
|
||||
>
|
||||
<span className={'button__content'}>
|
||||
<Icon aria-hidden icon={ICONS.PIN} className={'icon'} />
|
||||
@@ -205,20 +210,31 @@ function CommentMenuList(props: Props) {
|
||||
)}
|
||||
|
||||
{!commentIsMine && (
|
||||
<MenuItem className="comment__menu-option" onSelect={handleCommentBlock}>
|
||||
{getBlockOptionElem()}
|
||||
</MenuItem>
|
||||
<>
|
||||
<MenuItem
|
||||
className="comment__menu-option"
|
||||
onSelect={() => openModal(MODALS.BLOCK_CHANNEL, { contentUri: uri, commenterUri: authorUri })}
|
||||
>
|
||||
{getBlockOptionElem()}
|
||||
</MenuItem>
|
||||
<MenuItem className="comment__menu-option" onSelect={() => muteChannel(authorUri)}>
|
||||
<div className="menu__link">
|
||||
<Icon aria-hidden icon={ICONS.MUTE} />
|
||||
{__('Mute')}
|
||||
</div>
|
||||
{activeChannelIsCreator && (
|
||||
<span className="comment__menu-help">{__('Hide this channel for you only.')}</span>
|
||||
)}
|
||||
</MenuItem>
|
||||
</>
|
||||
)}
|
||||
|
||||
{!commentIsMine && (
|
||||
<MenuItem className="comment__menu-option" onSelect={handleCommentMute}>
|
||||
{IS_WEB && (
|
||||
<MenuItem className="comment__menu-option" onSelect={handleCopyCommentLink}>
|
||||
<div className="menu__link">
|
||||
<Icon aria-hidden icon={ICONS.MUTE} />
|
||||
{__('Mute')}
|
||||
<Icon aria-hidden icon={ICONS.COPY_LINK} />
|
||||
{__('Copy Link')}
|
||||
</div>
|
||||
{activeChannelIsCreator && (
|
||||
<span className="comment__menu-help">{__('Hide this channel for you only.')}</span>
|
||||
)}
|
||||
</MenuItem>
|
||||
)}
|
||||
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
// @flow
|
||||
import * as REACTION_TYPES from 'constants/reactions';
|
||||
import * as ICONS from 'constants/icons';
|
||||
import { COMMENT_HIGHLIGHTED } from 'constants/classnames';
|
||||
import { COMMENT_PAGE_SIZE_TOP_LEVEL, SORT_BY } from 'constants/comment';
|
||||
import React, { useEffect } from 'react';
|
||||
import classnames from 'classnames';
|
||||
import CommentView from 'component/comment';
|
||||
import Spinner from 'component/spinner';
|
||||
import { ENABLE_COMMENT_REACTIONS } from 'config';
|
||||
import { getChannelIdFromClaim } from 'util/claim';
|
||||
import { useIsMobile, useIsMediumScreen } from 'effects/use-screensize';
|
||||
import * as ICONS from 'constants/icons';
|
||||
import * as REACTION_TYPES from 'constants/reactions';
|
||||
import Button from 'component/button';
|
||||
import Card from 'component/common/card';
|
||||
import classnames from 'classnames';
|
||||
import CommentCreate from 'component/commentCreate';
|
||||
import usePersistedState from 'effects/use-persisted-state';
|
||||
import { ENABLE_COMMENT_REACTIONS } from 'config';
|
||||
import Empty from 'component/common/empty';
|
||||
import CommentView from 'component/comment';
|
||||
import debounce from 'util/debounce';
|
||||
import Empty from 'component/common/empty';
|
||||
import React, { useEffect } from 'react';
|
||||
import Spinner from 'component/spinner';
|
||||
import useFetched from 'effects/use-fetched';
|
||||
import { useIsMobile, useIsMediumScreen } from 'effects/use-screensize';
|
||||
import { getChannelIdFromClaim } from 'util/claim';
|
||||
import usePersistedState from 'effects/use-persisted-state';
|
||||
|
||||
const DEBOUNCE_SCROLL_HANDLER_MS = 200;
|
||||
|
||||
@@ -33,10 +33,6 @@ type Props = {
|
||||
pinnedComments: Array<Comment>,
|
||||
topLevelComments: Array<Comment>,
|
||||
topLevelTotalPages: number,
|
||||
fetchTopLevelComments: (string, number, number, number) => void,
|
||||
fetchComment: (string) => void,
|
||||
fetchReacts: (Array<string>) => Promise<any>,
|
||||
resetComments: (string) => void,
|
||||
uri: string,
|
||||
claim: ?Claim,
|
||||
claimIsMine: boolean,
|
||||
@@ -51,15 +47,16 @@ type Props = {
|
||||
othersReactsById: ?{ [string]: { [REACTION_TYPES.LIKE | REACTION_TYPES.DISLIKE]: number } },
|
||||
activeChannelId: ?string,
|
||||
settingsByChannelId: { [channelId: string]: PerChannelSettings },
|
||||
fetchReacts: (Array<string>) => Promise<any>,
|
||||
commentsAreExpanded?: boolean,
|
||||
fetchTopLevelComments: (string, number, number, number) => void,
|
||||
fetchComment: (string) => void,
|
||||
resetComments: (string) => void,
|
||||
};
|
||||
|
||||
function CommentList(props: Props) {
|
||||
const {
|
||||
allCommentIds,
|
||||
fetchTopLevelComments,
|
||||
fetchComment,
|
||||
fetchReacts,
|
||||
resetComments,
|
||||
uri,
|
||||
pinnedComments,
|
||||
topLevelComments,
|
||||
@@ -77,21 +74,28 @@ function CommentList(props: Props) {
|
||||
othersReactsById,
|
||||
activeChannelId,
|
||||
settingsByChannelId,
|
||||
fetchReacts,
|
||||
commentsAreExpanded,
|
||||
fetchTopLevelComments,
|
||||
fetchComment,
|
||||
resetComments,
|
||||
} = props;
|
||||
|
||||
const isMobile = useIsMobile();
|
||||
const isMediumScreen = useIsMediumScreen();
|
||||
const spinnerRef = React.useRef();
|
||||
const DEFAULT_SORT = ENABLE_COMMENT_REACTIONS ? SORT_BY.POPULARITY : SORT_BY.NEWEST;
|
||||
const [sort, setSort] = usePersistedState('comment-sort-by', DEFAULT_SORT);
|
||||
const [page, setPage] = React.useState(0);
|
||||
const isMobile = useIsMobile();
|
||||
const isMediumScreen = useIsMediumScreen();
|
||||
const [expandedComments, setExpandedComments] = React.useState(!isMobile && !isMediumScreen);
|
||||
const totalFetchedComments = allCommentIds ? allCommentIds.length : 0;
|
||||
const channelId = getChannelIdFromClaim(claim);
|
||||
const channelSettings = channelId ? settingsByChannelId[channelId] : undefined;
|
||||
const fetchedCommentsOnce = useFetched(isFetchingComments);
|
||||
const fetchedReactsOnce = useFetched(isFetchingReacts);
|
||||
const fetchedLinkedComment = useFetched(isFetchingCommentsById);
|
||||
const hasDefaultExpansion = commentsAreExpanded || (!isMobile && !isMediumScreen);
|
||||
const [expandedComments, setExpandedComments] = React.useState(hasDefaultExpansion);
|
||||
const totalFetchedComments = allCommentIds ? allCommentIds.length : 0;
|
||||
const channelId = getChannelIdFromClaim(claim);
|
||||
const channelSettings = channelId ? settingsByChannelId[channelId] : undefined;
|
||||
const moreBelow = page < topLevelTotalPages;
|
||||
|
||||
// Display comments immediately if not fetching reactions
|
||||
// If not, wait to show comments until reactions are fetched
|
||||
@@ -99,20 +103,6 @@ function CommentList(props: Props) {
|
||||
Boolean(othersReactsById) || !ENABLE_COMMENT_REACTIONS
|
||||
);
|
||||
|
||||
const hasNoComments = !totalComments;
|
||||
const moreBelow = page < topLevelTotalPages;
|
||||
|
||||
const isMyComment = (channelId: string): boolean => {
|
||||
if (myChannels != null && channelId != null) {
|
||||
for (let i = 0; i < myChannels.length; i++) {
|
||||
if (myChannels[i].claim_id === channelId) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
function changeSort(newSort) {
|
||||
if (sort !== newSort) {
|
||||
setSort(newSort);
|
||||
@@ -120,34 +110,6 @@ function CommentList(props: Props) {
|
||||
}
|
||||
}
|
||||
|
||||
function getCommentElems(comments) {
|
||||
return comments.map((comment) => {
|
||||
return (
|
||||
<CommentView
|
||||
isTopLevel
|
||||
threadDepth={3}
|
||||
key={comment.comment_id}
|
||||
uri={uri}
|
||||
authorUri={comment.channel_url}
|
||||
author={comment.channel_name}
|
||||
claimId={comment.claim_id}
|
||||
commentId={comment.comment_id}
|
||||
message={comment.comment}
|
||||
timePosted={comment.timestamp * 1000}
|
||||
claimIsMine={claimIsMine}
|
||||
commentIsMine={comment.channel_id && isMyComment(comment.channel_id)}
|
||||
linkedCommentId={linkedCommentId}
|
||||
isPinned={comment.is_pinned}
|
||||
supportAmount={comment.support_amount}
|
||||
numDirectReplies={comment.replies}
|
||||
isModerator={comment.is_moderator}
|
||||
isGlobalMod={comment.is_global_mod}
|
||||
isFiat={comment.is_fiat}
|
||||
/>
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
// Reset comments
|
||||
useEffect(() => {
|
||||
if (page === 0) {
|
||||
@@ -168,7 +130,7 @@ function CommentList(props: Props) {
|
||||
|
||||
fetchTopLevelComments(uri, page, COMMENT_PAGE_SIZE_TOP_LEVEL, sort);
|
||||
}
|
||||
}, [fetchTopLevelComments, uri, page, resetComments, sort, linkedCommentId, fetchComment]);
|
||||
}, [fetchComment, fetchTopLevelComments, linkedCommentId, page, sort, uri]);
|
||||
|
||||
// Fetch reacts
|
||||
useEffect(() => {
|
||||
@@ -193,15 +155,14 @@ function CommentList(props: Props) {
|
||||
}
|
||||
}
|
||||
}, [
|
||||
totalFetchedComments,
|
||||
allCommentIds,
|
||||
othersReactsById,
|
||||
myReactsByCommentId,
|
||||
fetchReacts,
|
||||
uri,
|
||||
activeChannelId,
|
||||
allCommentIds,
|
||||
fetchReacts,
|
||||
fetchingChannels,
|
||||
isFetchingReacts,
|
||||
myReactsByCommentId,
|
||||
othersReactsById,
|
||||
totalFetchedComments,
|
||||
]);
|
||||
|
||||
// Scroll to linked-comment
|
||||
@@ -223,9 +184,7 @@ function CommentList(props: Props) {
|
||||
// Infinite scroll
|
||||
useEffect(() => {
|
||||
function shouldFetchNextPage(page, topLevelTotalPages, window, document, yPrefetchPx = 1000) {
|
||||
if (!spinnerRef || !spinnerRef.current) {
|
||||
return false;
|
||||
}
|
||||
if (!spinnerRef || !spinnerRef.current) return false;
|
||||
|
||||
const rect = spinnerRef.current.getBoundingClientRect(); // $FlowFixMe
|
||||
const windowH = window.innerHeight || document.documentElement.clientHeight; // $FlowFixMe
|
||||
@@ -247,7 +206,7 @@ function CommentList(props: Props) {
|
||||
}
|
||||
|
||||
const handleCommentScroll = debounce(() => {
|
||||
if (!isMobile && !isMediumScreen && shouldFetchNextPage(page, topLevelTotalPages, window, document)) {
|
||||
if (hasDefaultExpansion && shouldFetchNextPage(page, topLevelTotalPages, window, document)) {
|
||||
setPage(page + 1);
|
||||
}
|
||||
}, DEBOUNCE_SCROLL_HANDLER_MS);
|
||||
@@ -260,86 +219,76 @@ function CommentList(props: Props) {
|
||||
return () => window.removeEventListener('scroll', handleCommentScroll);
|
||||
}
|
||||
}
|
||||
}, [
|
||||
isMobile,
|
||||
isMediumScreen,
|
||||
page,
|
||||
moreBelow,
|
||||
spinnerRef,
|
||||
isFetchingComments,
|
||||
readyToDisplayComments,
|
||||
topLevelComments.length,
|
||||
topLevelTotalPages,
|
||||
]);
|
||||
}, [hasDefaultExpansion, isFetchingComments, moreBelow, page, readyToDisplayComments, topLevelTotalPages]);
|
||||
|
||||
// Expand comments
|
||||
useEffect(() => {
|
||||
if (!isMobile && !isMediumScreen && !expandedComments) {
|
||||
setExpandedComments(true);
|
||||
}
|
||||
}, [isMobile, isMediumScreen, expandedComments]);
|
||||
const getCommentElems = (comments) => {
|
||||
return comments.map((comment) => (
|
||||
<CommentView
|
||||
isTopLevel
|
||||
threadDepth={3}
|
||||
key={comment.comment_id}
|
||||
uri={uri}
|
||||
authorUri={comment.channel_url}
|
||||
author={comment.channel_name}
|
||||
claimId={comment.claim_id}
|
||||
commentId={comment.comment_id}
|
||||
message={comment.comment}
|
||||
timePosted={comment.timestamp * 1000}
|
||||
claimIsMine={claimIsMine}
|
||||
commentIsMine={
|
||||
comment.channel_id && myChannels && myChannels.some(({ claim_id }) => claim_id === comment.channel_id)
|
||||
}
|
||||
linkedCommentId={linkedCommentId}
|
||||
isPinned={comment.is_pinned}
|
||||
supportAmount={comment.support_amount}
|
||||
numDirectReplies={comment.replies}
|
||||
isModerator={comment.is_moderator}
|
||||
isGlobalMod={comment.is_global_mod}
|
||||
isFiat={comment.is_fiat}
|
||||
/>
|
||||
));
|
||||
};
|
||||
|
||||
const sortButton = (label, icon, sortOption) => {
|
||||
return (
|
||||
<Button
|
||||
button="alt"
|
||||
label={label}
|
||||
icon={icon}
|
||||
iconSize={18}
|
||||
onClick={() => changeSort(sortOption)}
|
||||
className={classnames(`button-toggle`, {
|
||||
'button-toggle--active': sort === sortOption,
|
||||
})}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
<Card
|
||||
className="card--enable-overflow"
|
||||
title={
|
||||
totalComments > 0
|
||||
? totalComments === 1
|
||||
? __('1 comment')
|
||||
: __('%total_comments% comments', { total_comments: totalComments })
|
||||
: __('Leave a comment')
|
||||
(totalComments === 0 && __('Leave a comment')) ||
|
||||
(totalComments === 1 && __('1 comment')) ||
|
||||
__('%totalComments% comments', { totalComments })
|
||||
}
|
||||
titleActions={
|
||||
<>
|
||||
{totalComments > 1 && ENABLE_COMMENT_REACTIONS && (
|
||||
<span className="comment__sort">
|
||||
<Button
|
||||
button="alt"
|
||||
label={__('Best')}
|
||||
icon={ICONS.BEST}
|
||||
iconSize={18}
|
||||
onClick={() => changeSort(SORT_BY.POPULARITY)}
|
||||
className={classnames(`button-toggle`, {
|
||||
'button-toggle--active': sort === SORT_BY.POPULARITY,
|
||||
})}
|
||||
/>
|
||||
<Button
|
||||
button="alt"
|
||||
label={__('Controversial')}
|
||||
icon={ICONS.CONTROVERSIAL}
|
||||
iconSize={18}
|
||||
onClick={() => changeSort(SORT_BY.CONTROVERSY)}
|
||||
className={classnames(`button-toggle`, {
|
||||
'button-toggle--active': sort === SORT_BY.CONTROVERSY,
|
||||
})}
|
||||
/>
|
||||
<Button
|
||||
button="alt"
|
||||
label={__('New')}
|
||||
icon={ICONS.NEW}
|
||||
iconSize={18}
|
||||
onClick={() => changeSort(SORT_BY.NEWEST)}
|
||||
className={classnames(`button-toggle`, {
|
||||
'button-toggle--active': sort === SORT_BY.NEWEST,
|
||||
})}
|
||||
/>
|
||||
{sortButton(__('Best'), ICONS.BEST, SORT_BY.POPULARITY)}
|
||||
{sortButton(__('Controversial'), ICONS.CONTROVERSIAL, SORT_BY.CONTROVERSY)}
|
||||
{sortButton(__('New'), ICONS.NEW, SORT_BY.NEWEST)}
|
||||
</span>
|
||||
)}
|
||||
<Button
|
||||
button="alt"
|
||||
icon={ICONS.REFRESH}
|
||||
title={__('Refresh')}
|
||||
onClick={() => {
|
||||
setPage(0);
|
||||
}}
|
||||
/>
|
||||
<Button button="alt" icon={ICONS.REFRESH} title={__('Refresh')} onClick={() => setPage(0)} />
|
||||
</>
|
||||
}
|
||||
actions={
|
||||
<>
|
||||
<CommentCreate uri={uri} />
|
||||
|
||||
{channelSettings && channelSettings.comments_enabled && !isFetchingComments && hasNoComments && (
|
||||
{channelSettings && channelSettings.comments_enabled && !isFetchingComments && !totalComments && (
|
||||
<Empty padded text={__('That was pretty deep. What do you think?')} />
|
||||
)}
|
||||
|
||||
@@ -353,36 +302,28 @@ function CommentList(props: Props) {
|
||||
{readyToDisplayComments && topLevelComments && getCommentElems(topLevelComments)}
|
||||
</ul>
|
||||
|
||||
{(isMobile || isMediumScreen) && (
|
||||
{!hasDefaultExpansion && (
|
||||
<div className="card__bottom-actions--comments">
|
||||
{(!expandedComments || moreBelow) && (
|
||||
<Button
|
||||
button="link"
|
||||
title={!expandedComments ? __('Expand Comments') : __('Load More')}
|
||||
title={!expandedComments ? __('Expand') : __('More')}
|
||||
label={!expandedComments ? __('Expand') : __('More')}
|
||||
onClick={() => {
|
||||
if (!expandedComments) {
|
||||
setExpandedComments(true);
|
||||
} else {
|
||||
setPage(page + 1);
|
||||
}
|
||||
}}
|
||||
onClick={() => (!expandedComments ? setExpandedComments(true) : setPage(page + 1))}
|
||||
/>
|
||||
)}
|
||||
{expandedComments && (
|
||||
<Button
|
||||
button="link"
|
||||
title={__('Collapse Thread')}
|
||||
title={__('Collapse')}
|
||||
label={__('Collapse')}
|
||||
onClick={() => {
|
||||
setExpandedComments(false);
|
||||
}}
|
||||
onClick={() => setExpandedComments(false)}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{(isFetchingComments || (!isMobile && !isMediumScreen && moreBelow)) && (
|
||||
{(isFetchingComments || (hasDefaultExpansion && moreBelow)) && (
|
||||
<div className="main--empty" ref={spinnerRef}>
|
||||
<Spinner type="small" />
|
||||
</div>
|
||||
|
||||
@@ -9,6 +9,9 @@ import { useIsMobile, useIsMediumScreen } from 'effects/use-screensize';
|
||||
import Button from 'component/button';
|
||||
import classnames from 'classnames';
|
||||
import RecSys from 'recsys';
|
||||
import { FormField } from '../common/form-components/form-field';
|
||||
import I18nMessage from '../i18nMessage';
|
||||
import CreditAmount from '../common/credit-amount';
|
||||
|
||||
const VIEW_ALL_RELATED = 'view_all_related';
|
||||
const VIEW_MORE_FROM = 'view_more_from';
|
||||
@@ -36,6 +39,8 @@ export default React.memo<Props>(function RecommendedContent(props: Props) {
|
||||
claimId,
|
||||
} = props;
|
||||
const [viewMode, setViewMode] = React.useState(VIEW_ALL_RELATED);
|
||||
const [strict, setStrict] = React.useState(false);
|
||||
const [wordCount, setWordCount] = React.useState(3);
|
||||
const signingChannel = claim && claim.signing_channel;
|
||||
const channelName = signingChannel ? signingChannel.name : null;
|
||||
const isMobile = useIsMobile();
|
||||
@@ -64,14 +69,81 @@ export default React.memo<Props>(function RecommendedContent(props: Props) {
|
||||
}
|
||||
}
|
||||
|
||||
function getSearchTextForClaim(claim) {
|
||||
const wordMap = {};
|
||||
|
||||
const addToWordmap = (word) => {
|
||||
if (wordMap[word]) {
|
||||
wordMap[word]++;
|
||||
} else {
|
||||
wordMap[word] = 1;
|
||||
}
|
||||
};
|
||||
|
||||
claim.name.split('-').map((word) => addToWordmap(word));
|
||||
if (claim.value.title) {
|
||||
claim.value.title.split(' ').map((word) => addToWordmap(word));
|
||||
}
|
||||
if (claim.value.tags) {
|
||||
claim.value.tags.forEach((tag) => tag.split(' ').map((word) => addToWordmap(word)));
|
||||
}
|
||||
if (claim.value.description) {
|
||||
claim.value.description.split(' ').map((word) => addToWordmap(word));
|
||||
}
|
||||
console.log('wordMap', wordMap);
|
||||
|
||||
const sorted = Object.entries(wordMap)
|
||||
.sort(([, a], [, b]) => b - a)
|
||||
.map(([el, val]) => el)
|
||||
.filter((e) => e.length >= 4);
|
||||
let searchText = sorted.slice(0, wordCount).join(strict ? ' +' : ' ');
|
||||
console.log('searchText', searchText);
|
||||
// console.log('claim.title');
|
||||
// if (claim.value && claim.value.title) {
|
||||
// searchText += claim.value.title;
|
||||
// }
|
||||
// if (claim.value.description) {
|
||||
// searchText += claim.value.description;
|
||||
// }
|
||||
console.log('searchText', searchText);
|
||||
return searchText;
|
||||
}
|
||||
|
||||
const searchText = claim ? getSearchTextForClaim(claim) : undefined;
|
||||
|
||||
return (
|
||||
<Card
|
||||
isBodyList
|
||||
smallTitle={!isMobile && !isMedium}
|
||||
className="file-page__recommended"
|
||||
title={__('Related')}
|
||||
titleActions={
|
||||
signingChannel && (
|
||||
// title={__('Related')}
|
||||
// titleActions={
|
||||
// signingChannel && (
|
||||
// <>
|
||||
//
|
||||
// <div className="recommended-content__toggles">
|
||||
//
|
||||
// <Button
|
||||
// className={classnames('button-toggle', {
|
||||
// 'button-toggle--active': viewMode === VIEW_ALL_RELATED,
|
||||
// })}
|
||||
// label={__('All')}
|
||||
// onClick={() => setViewMode(VIEW_ALL_RELATED)}
|
||||
// />
|
||||
//
|
||||
// <Button
|
||||
// className={classnames('button-toggle', {
|
||||
// 'button-toggle--active': viewMode === VIEW_MORE_FROM,
|
||||
// })}
|
||||
// label={__('More from %claim_name%', { claim_name: channelName })}
|
||||
// onClick={() => setViewMode(VIEW_MORE_FROM)}
|
||||
// />
|
||||
// </div>
|
||||
// </>
|
||||
// )
|
||||
// }
|
||||
subtitle={
|
||||
<div className="card__whatever">
|
||||
<div className="recommended-content__toggles">
|
||||
<Button
|
||||
className={classnames('button-toggle', {
|
||||
@@ -89,21 +161,73 @@ export default React.memo<Props>(function RecommendedContent(props: Props) {
|
||||
onClick={() => setViewMode(VIEW_MORE_FROM)}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
<div className="section section__actions--between">
|
||||
<FormField
|
||||
name="word_count"
|
||||
label={__('Word Count')}
|
||||
min="0"
|
||||
step="1"
|
||||
type="number"
|
||||
value={wordCount}
|
||||
onChange={(event) => setWordCount(event.target.value)}
|
||||
/>
|
||||
<FormField
|
||||
name="search_strict"
|
||||
label={__('Strict')}
|
||||
type="checkbox"
|
||||
checked={strict}
|
||||
onChange={() => setStrict(!strict)}
|
||||
/>
|
||||
</div>
|
||||
<p>{searchText}</p>
|
||||
</div>
|
||||
}
|
||||
body={
|
||||
<div>
|
||||
{viewMode === VIEW_ALL_RELATED && (
|
||||
{viewMode === VIEW_ALL_RELATED && IS_WEB && (
|
||||
<ClaimList
|
||||
type="small"
|
||||
loading={isSearching}
|
||||
uris={recommendedContentUris}
|
||||
hideMenu={isMobile}
|
||||
infiniteScroll
|
||||
injectedItem={SHOW_ADS && IS_WEB && !isAuthenticated && <Ads small type={'video'} />}
|
||||
empty={__('No related content found')}
|
||||
onClick={handleRecommendationClicked}
|
||||
/>
|
||||
)}
|
||||
{/*{viewMode === VIEW_ALL_RELATED && !IS_WEB && (*/}
|
||||
{/* <ClaimList*/}
|
||||
{/* type="small"*/}
|
||||
{/* loading={isSearching}*/}
|
||||
{/* uris={recommendedContentUris}*/}
|
||||
{/* hideMenu={isMobile}*/}
|
||||
{/* infiniteScroll*/}
|
||||
{/* injectedItem={SHOW_ADS && IS_WEB && !isAuthenticated && <Ads small type={'video'} />}*/}
|
||||
{/* empty={__('No related content found')}*/}
|
||||
{/* onClick={handleRecommendationClicked}*/}
|
||||
{/* />*/}
|
||||
{/*)}*/}
|
||||
{viewMode === VIEW_ALL_RELATED && !IS_WEB && (
|
||||
<ClaimListDiscover
|
||||
hideAdvancedFilter
|
||||
tileLayout={false}
|
||||
showHeader={false}
|
||||
type="small"
|
||||
claimType={['stream']}
|
||||
// orderBy={['trending_group', 'trending_mixed']}
|
||||
orderBy={'new'}
|
||||
pageSize={20}
|
||||
infiniteScroll
|
||||
hideFilters
|
||||
searchText={searchText}
|
||||
// channelIds={[signingChannel.claim_id]}
|
||||
loading={isSearching}
|
||||
hideMenu={isMobile}
|
||||
injectedItem={SHOW_ADS && IS_WEB && !isAuthenticated && <Ads small type={'video'} />}
|
||||
empty={__('No related content found')}
|
||||
/>
|
||||
)}
|
||||
{viewMode === VIEW_MORE_FROM && signingChannel && (
|
||||
<ClaimListDiscover
|
||||
hideAdvancedFilter
|
||||
@@ -113,7 +237,7 @@ export default React.memo<Props>(function RecommendedContent(props: Props) {
|
||||
claimType={['stream']}
|
||||
orderBy="new"
|
||||
pageSize={20}
|
||||
infiniteScroll={false}
|
||||
infiniteScroll={true}
|
||||
hideFilters
|
||||
channelIds={[signingChannel.claim_id]}
|
||||
loading={isSearching}
|
||||
|
||||
@@ -7,7 +7,7 @@ import Icon from 'component/common/icon';
|
||||
import LbcMessage from 'component/common/lbc-message';
|
||||
|
||||
type Props = {
|
||||
removeSnack: any => void,
|
||||
removeSnack: (any) => void,
|
||||
snack: ?{
|
||||
linkTarget: ?string,
|
||||
linkText: ?string,
|
||||
@@ -53,9 +53,9 @@ class SnackBar extends React.PureComponent<Props> {
|
||||
<div className="snack-bar__message">
|
||||
<Icon icon={isError ? ICONS.ALERT : ICONS.COMPLETED} size={18} />
|
||||
|
||||
<div>
|
||||
<p className="snack-bar__messageText">
|
||||
<LbcMessage>{message}</LbcMessage>
|
||||
</div>
|
||||
</p>
|
||||
</div>
|
||||
{linkText && linkTarget && (
|
||||
// This is a little weird because of `linkTarget` code in `lbry-redux`
|
||||
|
||||
@@ -220,7 +220,7 @@ function FilePage(props: Props) {
|
||||
{!collection && !isMarkdown && !videoTheaterMode && <RecommendedContent uri={uri} />}
|
||||
{isMarkdown && (
|
||||
<div className="file-page__post-comments">
|
||||
<CommentsList uri={uri} linkedCommentId={linkedCommentId} />
|
||||
<CommentsList uri={uri} linkedCommentId={linkedCommentId} commentsAreExpanded />
|
||||
</div>
|
||||
)}
|
||||
</Page>
|
||||
|
||||
@@ -200,6 +200,9 @@ $thumbnailWidthSmall: 1rem;
|
||||
}
|
||||
|
||||
.comment__body-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-width: 0;
|
||||
flex: 1;
|
||||
margin-left: var(--spacing-xs);
|
||||
|
||||
|
||||
@@ -27,8 +27,6 @@ $recent-msg-button__height: 2rem;
|
||||
|
||||
.livestream__discussion {
|
||||
width: 100%;
|
||||
margin-top: var(--spacing-m);
|
||||
margin-bottom: var(--spacing-s);
|
||||
|
||||
@media (min-width: $breakpoint-medium) {
|
||||
margin: 0;
|
||||
|
||||
@@ -207,17 +207,43 @@
|
||||
}
|
||||
|
||||
.main--livestream {
|
||||
width: calc(100vw - var(--spacing-xs) * 2);
|
||||
margin: var(--spacing-xs);
|
||||
@extend .main--file-page;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
max-width: none;
|
||||
|
||||
@media (min-width: $breakpoint-medium) {
|
||||
margin: var(--spacing-m);
|
||||
margin-right: calc(var(--livestream-comments-width) + var(--spacing-m));
|
||||
width: calc(100vw - var(--livestream-comments-width) - var(--spacing-m) * 2);
|
||||
.card-stack {
|
||||
margin-top: var(--spacing-m);
|
||||
margin-bottom: var(--spacing-m);
|
||||
|
||||
@media (min-width: $breakpoint-large + 300px) {
|
||||
max-width: calc(var(--page-max-width--filepage) / 1.25);
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
@media (min-width: $breakpoint-medium) and (max-width: $breakpoint-large + 300px) {
|
||||
max-width: calc(100vw - var(--livestream-comments-width) - var(--spacing-m) * 3);
|
||||
margin-left: var(--spacing-m);
|
||||
margin-right: var(--spacing-m);
|
||||
}
|
||||
|
||||
@media (max-width: $breakpoint-medium) {
|
||||
max-width: none;
|
||||
}
|
||||
}
|
||||
|
||||
@media (min-width: $breakpoint-large) {
|
||||
margin-right: calc(10vw + var(--livestream-comments-width) + var(--spacing-m));
|
||||
.main__right-side {
|
||||
width: var(--livestream-comments-width);
|
||||
|
||||
@media (max-width: $breakpoint-medium) {
|
||||
width: 100%;
|
||||
margin-bottom: var(--spacing-m);
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: $breakpoint-medium) {
|
||||
padding: 0 var(--spacing-m);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -47,8 +47,6 @@
|
||||
}
|
||||
|
||||
.snack-bar__message {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
align-items: center;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
@@ -64,3 +62,8 @@
|
||||
min-width: 1rem;
|
||||
}
|
||||
}
|
||||
.snack-bar__messageText {
|
||||
min-width: 0;
|
||||
text-overflow: ellipsis;
|
||||
overflow: hidden;
|
||||
}
|
||||
Reference in new issue
Block a user