Compare commits

..
1 Commits
Author SHA1 Message Date
Branko Tomic e3ca8f7c40 Prevent comment content from breaking the layout on mobile 2021-10-04 21:55:14 -04:00
4 changed files with 24 additions and 34 deletions

No files matched your search

+16 -22
View File
@@ -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 -3
View File
@@ -361,9 +361,7 @@ function Comment(props: Props) {
icon={ICONS.REPLY}
/>
)}
{ENABLE_COMMENT_REACTIONS && (
<CommentReactions uri={uri} commentId={commentId} othersReacts={othersReacts} />
)}
{ENABLE_COMMENT_REACTIONS && <CommentReactions uri={uri} commentId={commentId} />}
</div>
)}
+3 -3
View File
@@ -1,5 +1,5 @@
import { connect } from 'react-redux';
import CommentReactions from './view';
import Comment from './view';
import { makeSelectClaimIsMine, makeSelectClaimForUri, doResolveUri } from 'lbry-redux';
import { doToast } from 'redux/actions/notifications';
import { makeSelectMyReactionsForComment, makeSelectOthersReactionsForComment } from 'redux/selectors/comments';
@@ -15,7 +15,7 @@ const select = (state, props) => {
claim: makeSelectClaimForUri(props.uri)(state),
claimIsMine: makeSelectClaimIsMine(props.uri)(state),
myReacts: makeSelectMyReactionsForComment(reactionKey)(state),
othersReacts: props.othersReacts || makeSelectOthersReactionsForComment(reactionKey)(state),
othersReacts: makeSelectOthersReactionsForComment(reactionKey)(state),
activeChannelId,
};
};
@@ -26,4 +26,4 @@ const perform = (dispatch) => ({
doToast: (params) => dispatch(doToast(params)),
});
export default connect(select, perform)(CommentReactions);
export default connect(select, perform)(Comment);
+4 -6
View File
@@ -5,8 +5,6 @@ import { selectShowMatureContent } from 'redux/selectors/settings';
import { selectBlacklistedOutpointMap, selectFilteredOutpointMap } from 'lbryinc';
import { selectClaimsById, isClaimNsfw, selectMyActiveClaims } from 'lbry-redux';
type State = { comments: CommentsState };
const selectState = (state) => state.comments || {};
export const selectCommentsById = createSelector(selectState, (state) => state.commentById || {});
@@ -15,7 +13,7 @@ export const selectIsFetchingCommentsById = createSelector(selectState, (state)
export const selectIsFetchingCommentsByParentId = createSelector(selectState, (state) => state.isLoadingByParentId);
export const selectIsPostingComment = createSelector(selectState, (state) => state.isCommenting);
export const selectIsFetchingReacts = createSelector(selectState, (state) => state.isFetchingReacts);
export const selectOthersReactsById = (state: State) => state.comments.othersReactsByCommentId;
export const selectOthersReactsById = createSelector(selectState, (state) => state.othersReactsByCommentId);
export const selectPinnedCommentsById = createSelector(selectState, (state) => state.pinnedCommentsById);
export const makeSelectPinnedCommentsForUri = (uri: string) =>
@@ -193,12 +191,12 @@ export const makeSelectMyReactionsForComment = (commentIdChannelId: string) =>
});
export const makeSelectOthersReactionsForComment = (commentId: string) =>
createSelector(selectOthersReactsById, (othersReactsByCommentId) => {
if (!othersReactsByCommentId) {
createSelector(selectState, (state) => {
if (!state.othersReactsByCommentId) {
return {};
}
return othersReactsByCommentId[commentId] || {};
return state.othersReactsByCommentId[commentId] || {};
});
export const selectPendingCommentReacts = createSelector(selectState, (state) => state.pendingCommentReactions);