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

53 lines
2.1 KiB
JavaScript
Raw Permalink Normal View History

2019-05-17 20:21:07 +02:00
import { connect } from 'react-redux';
import {
makeSelectClaimForUri,
makeSelectClaimIsMine,
selectFetchingMyChannels,
selectMyChannelClaims,
} from 'lbry-redux';
2020-09-30 20:46:17 +02:00
import {
makeSelectTopLevelCommentsForUri,
makeSelectTopLevelTotalPagesForUri,
2020-09-30 20:46:17 +02:00
selectIsFetchingComments,
selectIsFetchingReacts,
2020-09-30 20:46:17 +02:00
makeSelectTotalCommentsCountForUri,
selectOthersReactsById,
selectMyReactionsByCommentId,
makeSelectCommentIdsForUri,
selectSettingsByChannelId,
makeSelectPinnedCommentsForUri,
2020-09-30 20:46:17 +02:00
} from 'redux/selectors/comments';
import { doCommentReset, doCommentList, doCommentById, doCommentReactList } from 'redux/actions/comments';
import { selectActiveChannelClaim } from 'redux/selectors/app';
import CommentsList from './view';
2019-05-17 20:21:07 +02:00
const select = (state, props) => {
const activeChannelClaim = selectActiveChannelClaim(state);
return {
myChannels: selectMyChannelClaims(state),
allCommentIds: makeSelectCommentIdsForUri(props.uri)(state),
pinnedComments: makeSelectPinnedCommentsForUri(props.uri)(state),
topLevelComments: makeSelectTopLevelCommentsForUri(props.uri)(state),
topLevelTotalPages: makeSelectTopLevelTotalPagesForUri(props.uri)(state),
totalComments: makeSelectTotalCommentsCountForUri(props.uri)(state),
claim: makeSelectClaimForUri(props.uri)(state),
claimIsMine: makeSelectClaimIsMine(props.uri)(state),
isFetchingComments: selectIsFetchingComments(state),
isFetchingReacts: selectIsFetchingReacts(state),
fetchingChannels: selectFetchingMyChannels(state),
settingsByChannelId: selectSettingsByChannelId(state),
myReactsByCommentId: selectMyReactionsByCommentId(state),
othersReactsById: selectOthersReactsById(state),
activeChannelId: activeChannelClaim && activeChannelClaim.claim_id,
};
};
2019-05-17 20:21:07 +02:00
const perform = (dispatch) => ({
fetchTopLevelComments: (uri, page, pageSize, sortBy) => dispatch(doCommentList(uri, '', page, pageSize, sortBy)),
fetchComment: (commentId) => dispatch(doCommentById(commentId)),
fetchReacts: (commentIds) => dispatch(doCommentReactList(commentIds)),
resetComments: (uri) => dispatch(doCommentReset(uri)),
2019-05-17 20:21:07 +02:00
});
2019-06-27 01:59:27 +02:00
export default connect(select, perform)(CommentsList);