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

63 lines
2.2 KiB
JavaScript
Raw Normal View History

2019-05-17 20:21:07 +02:00
import { connect } from 'react-redux';
import {
selectClaimForUri,
selectClaimIsMine,
selectFetchingMyChannels,
selectClaimsByUri,
} from 'redux/selectors/claims';
2020-09-30 20:46:17 +02:00
import {
2021-10-11 08:02:17 +02:00
selectTopLevelCommentsForUri,
makeSelectTopLevelTotalPagesForUri,
2020-09-30 20:46:17 +02:00
selectIsFetchingComments,
selectIsFetchingCommentsById,
selectIsFetchingReacts,
selectTotalCommentsCountForUri,
selectOthersReacts,
selectMyReacts,
selectCommentIdsForUri,
selectSettingsByChannelId,
2021-10-11 08:02:17 +02:00
selectPinnedCommentsForUri,
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 { getChannelIdFromClaim } from 'util/claim';
import { doFetchUserMemberships } from 'redux/actions/user';
import CommentsList from './view';
2019-05-17 20:21:07 +02:00
const select = (state, props) => {
const { uri } = props;
const claim = selectClaimForUri(state, uri);
const activeChannelClaim = selectActiveChannelClaim(state);
return {
topLevelComments: selectTopLevelCommentsForUri(state, uri),
allCommentIds: selectCommentIdsForUri(state, uri),
pinnedComments: selectPinnedCommentsForUri(state, uri),
topLevelTotalPages: makeSelectTopLevelTotalPagesForUri(uri)(state),
totalComments: selectTotalCommentsCountForUri(state, uri),
claimId: claim && claim.claim_id,
channelId: getChannelIdFromClaim(claim),
claimIsMine: selectClaimIsMine(state, claim),
isFetchingComments: selectIsFetchingComments(state),
isFetchingCommentsById: selectIsFetchingCommentsById(state),
isFetchingReacts: selectIsFetchingReacts(state),
fetchingChannels: selectFetchingMyChannels(state),
settingsByChannelId: selectSettingsByChannelId(state),
myReactsByCommentId: selectMyReacts(state),
othersReactsById: selectOthersReacts(state),
activeChannelId: activeChannelClaim && activeChannelClaim.claim_id,
claimsByUri: selectClaimsByUri(state),
};
};
2019-05-17 20:21:07 +02:00
const perform = {
fetchTopLevelComments: doCommentList,
fetchComment: doCommentById,
fetchReacts: doCommentReactList,
resetComments: doCommentReset,
doFetchUserMemberships,
};
2019-06-27 01:59:27 +02:00
export default connect(select, perform)(CommentsList);