2020-08-24 19:35:21 +02:00
|
|
|
import { connect } from 'react-redux';
|
2021-10-11 08:02:17 +02:00
|
|
|
import { doResolveUris } from 'redux/actions/claims';
|
2022-02-09 16:27:11 +01:00
|
|
|
import { selectClaimIsMineForUri, makeSelectClaimForUri } from 'redux/selectors/claims';
|
2021-10-11 08:02:17 +02:00
|
|
|
import { selectIsFetchingCommentsByParentId, selectRepliesForParentId } from 'redux/selectors/comments';
|
2020-08-25 21:54:06 +02:00
|
|
|
import CommentsReplies from './view';
|
2020-08-24 19:35:21 +02:00
|
|
|
|
2021-10-11 08:02:17 +02:00
|
|
|
const select = (state, props) => {
|
|
|
|
const fetchedReplies = selectRepliesForParentId(state, props.parentId);
|
|
|
|
const resolvedReplies =
|
|
|
|
fetchedReplies && fetchedReplies.length > 0
|
|
|
|
? fetchedReplies.filter(({ channel_url }) => makeSelectClaimForUri(channel_url)(state) !== undefined)
|
|
|
|
: [];
|
2020-08-24 19:35:21 +02:00
|
|
|
|
2021-10-11 08:02:17 +02:00
|
|
|
return {
|
|
|
|
fetchedReplies,
|
|
|
|
resolvedReplies,
|
2022-02-09 16:27:11 +01:00
|
|
|
claimIsMine: selectClaimIsMineForUri(state, props.uri),
|
2022-01-07 20:02:33 +01:00
|
|
|
userCanComment: true,
|
2021-10-11 08:02:17 +02:00
|
|
|
isFetchingByParentId: selectIsFetchingCommentsByParentId(state),
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
const perform = (dispatch) => ({ doResolveUris: (uris) => dispatch(doResolveUris(uris, true)) });
|
|
|
|
|
|
|
|
export default connect(select, perform)(CommentsReplies);
|