lbry-desktop/ui/component/comment/index.js

56 lines
2.4 KiB
JavaScript
Raw Normal View History

2019-06-27 01:59:27 +02:00
import { connect } from 'react-redux';
2019-10-23 09:04:40 +02:00
import {
doResolveUri,
makeSelectClaimIsPending,
makeSelectClaimForUri,
makeSelectThumbnailForUri,
makeSelectIsUriResolving,
selectMyChannelClaims,
2020-10-20 05:20:38 +02:00
makeSelectMyChannelPermUrlForName,
makeSelectChannelPermUrlForClaimUri,
2019-10-23 09:04:40 +02:00
} from 'lbry-redux';
2020-10-20 05:20:38 +02:00
import { doCommentAbandon, doCommentUpdate, doCommentPin, doCommentList } from 'redux/actions/comments';
2020-07-15 18:36:40 +02:00
import { doToggleBlockChannel } from 'redux/actions/blocked';
import { selectChannelIsBlocked } from 'redux/selectors/blocked';
import { doToast } from 'redux/actions/notifications';
2021-01-26 20:50:44 +01:00
import { doSetPlayingUri } from 'redux/actions/content';
2020-08-24 19:35:21 +02:00
import { selectUserVerifiedEmail } from 'redux/selectors/user';
2020-10-20 05:20:38 +02:00
import {
selectIsFetchingComments,
makeSelectOthersReactionsForComment,
selectCommentChannel,
} from 'redux/selectors/comments';
import Comment from './view';
2019-06-27 01:59:27 +02:00
2020-10-20 05:20:38 +02:00
const select = (state, props) => {
const channel = selectCommentChannel(state);
return {
activeChannel: channel,
pending: props.authorUri && makeSelectClaimIsPending(props.authorUri)(state),
channel: props.authorUri && makeSelectClaimForUri(props.authorUri)(state),
isResolvingUri: props.authorUri && makeSelectIsUriResolving(props.authorUri)(state),
thumbnail: props.authorUri && makeSelectThumbnailForUri(props.authorUri)(state),
channelIsBlocked: props.authorUri && selectChannelIsBlocked(props.authorUri)(state),
commentingEnabled: IS_WEB ? Boolean(selectUserVerifiedEmail(state)) : true,
isFetchingComments: selectIsFetchingComments(state),
myChannels: selectMyChannelClaims(state),
othersReacts: makeSelectOthersReactionsForComment(props.commentId)(state),
commentIdentityChannel: makeSelectMyChannelPermUrlForName(channel)(state),
contentChannel: makeSelectChannelPermUrlForClaimUri(props.uri)(state),
};
};
2019-10-23 09:04:40 +02:00
const perform = dispatch => ({
2021-01-26 20:50:44 +01:00
closeInlinePlayer: () => dispatch(doSetPlayingUri({ uri: null })),
2019-10-23 09:04:40 +02:00
resolveUri: uri => dispatch(doResolveUri(uri)),
updateComment: (commentId, comment) => dispatch(doCommentUpdate(commentId, comment)),
deleteComment: commentId => dispatch(doCommentAbandon(commentId)),
2020-07-15 18:36:40 +02:00
blockChannel: channelUri => dispatch(doToggleBlockChannel(channelUri)),
doToast: options => dispatch(doToast(options)),
2020-10-20 05:20:38 +02:00
pinComment: (commentId, remove) => dispatch(doCommentPin(commentId, remove)),
fetchComments: uri => dispatch(doCommentList(uri)),
2019-10-23 09:04:40 +02:00
});
export default connect(select, perform)(Comment);