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

28 lines
1.2 KiB
JavaScript
Raw Normal View History

2020-08-24 19:35:21 +02:00
import { connect } from 'react-redux';
import { doResolveUris } from 'redux/actions/claims';
import { selectClaimIsMineForUri, selectMyChannelClaimIds, makeSelectClaimForUri } from 'redux/selectors/claims';
2021-10-11 08:02:17 +02:00
import { selectIsFetchingCommentsByParentId, selectRepliesForParentId } 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
const select = (state, props) => {
2021-10-11 08:02:17 +02:00
const fetchedReplies = selectRepliesForParentId(state, props.parentId);
2021-10-14 13:24:21 +02:00
const resolvedReplies =
fetchedReplies && fetchedReplies.length > 0
? fetchedReplies.filter(({ channel_url }) => makeSelectClaimForUri(channel_url)(state) !== undefined)
: [];
return {
fetchedReplies,
resolvedReplies,
claimIsMine: selectClaimIsMineForUri(state, props.uri),
userCanComment: IS_WEB ? Boolean(selectUserVerifiedEmail(state)) : true,
myChannelIds: selectMyChannelClaimIds(state),
isFetchingByParentId: selectIsFetchingCommentsByParentId(state),
};
};
const perform = (dispatch) => ({ doResolveUris: (uris) => dispatch(doResolveUris(uris, true)) });
export default connect(select, perform)(CommentsReplies);