2020-08-24 19:35:21 +02:00
|
|
|
import { connect } from 'react-redux';
|
2021-10-13 22:28:19 +02:00
|
|
|
import { makeSelectClaimIsMine, selectMyChannelClaims, makeSelectClaimForUri, doResolveUris } from 'lbry-redux';
|
2021-08-04 17:01:31 +02:00
|
|
|
import { selectIsFetchingCommentsByParentId, makeSelectRepliesForParentId } from 'redux/selectors/comments';
|
2020-08-24 19:35:21 +02:00
|
|
|
import { selectUserVerifiedEmail } from 'redux/selectors/user';
|
2020-08-25 21:54:06 +02:00
|
|
|
import CommentsReplies from './view';
|
2020-08-24 19:35:21 +02:00
|
|
|
|
2021-10-13 22:28:19 +02:00
|
|
|
const select = (state, props) => {
|
|
|
|
const fetchedReplies = makeSelectRepliesForParentId(props.parentId)(state);
|
2021-10-14 13:24:21 +02:00
|
|
|
const resolvedReplies =
|
|
|
|
fetchedReplies && fetchedReplies.length > 0
|
|
|
|
? fetchedReplies.filter(({ channel_url }) => makeSelectClaimForUri(channel_url)(state) !== undefined)
|
|
|
|
: [];
|
2021-10-13 22:28:19 +02:00
|
|
|
|
|
|
|
return {
|
|
|
|
fetchedReplies,
|
|
|
|
resolvedReplies,
|
|
|
|
claimIsMine: makeSelectClaimIsMine(props.uri)(state),
|
|
|
|
userCanComment: IS_WEB ? Boolean(selectUserVerifiedEmail(state)) : true,
|
|
|
|
myChannels: selectMyChannelClaims(state),
|
|
|
|
isFetchingByParentId: selectIsFetchingCommentsByParentId(state),
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
const perform = (dispatch) => ({ doResolveUris: (uris) => dispatch(doResolveUris(uris, true)) });
|
|
|
|
|
|
|
|
export default connect(select, perform)(CommentsReplies);
|