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,
|
|
|
|
} from 'lbry-redux';
|
2020-07-16 19:00:33 +02:00
|
|
|
import { doCommentAbandon, doCommentUpdate } from 'redux/actions/comments';
|
2020-07-15 18:36:40 +02:00
|
|
|
import { doToggleBlockChannel } from 'redux/actions/blocked';
|
2020-07-15 15:50:08 +02:00
|
|
|
import { selectChannelIsBlocked } from 'redux/selectors/blocked';
|
2019-06-27 01:59:27 +02:00
|
|
|
import Comment from './view';
|
2020-08-24 19:35:21 +02:00
|
|
|
import { selectUserVerifiedEmail } from 'redux/selectors/user';
|
|
|
|
import { selectIsFetchingComments } from 'redux/selectors/comments';
|
2019-06-27 01:59:27 +02:00
|
|
|
|
2019-10-23 09:04:40 +02:00
|
|
|
const select = (state, props) => ({
|
|
|
|
pending: props.authorUri && makeSelectClaimIsPending(props.authorUri)(state),
|
2020-01-30 02:02:21 +01:00
|
|
|
channel: props.authorUri && makeSelectClaimForUri(props.authorUri)(state),
|
2019-10-23 09:04:40 +02:00
|
|
|
isResolvingUri: props.authorUri && makeSelectIsUriResolving(props.authorUri)(state),
|
|
|
|
thumbnail: props.authorUri && makeSelectThumbnailForUri(props.authorUri)(state),
|
|
|
|
channelIsBlocked: props.authorUri && selectChannelIsBlocked(props.authorUri)(state),
|
2020-08-24 19:35:21 +02:00
|
|
|
commentingEnabled: IS_WEB ? Boolean(selectUserVerifiedEmail(state)) : true,
|
|
|
|
isFetchingComments: selectIsFetchingComments(state),
|
2019-10-23 09:04:40 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
const perform = dispatch => ({
|
|
|
|
resolveUri: uri => dispatch(doResolveUri(uri)),
|
2020-01-30 02:02:21 +01:00
|
|
|
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)),
|
2019-10-23 09:04:40 +02:00
|
|
|
});
|
|
|
|
|
2020-01-30 02:02:21 +01:00
|
|
|
export default connect(select, perform)(Comment);
|