2019-05-17 20:21:07 +02:00
|
|
|
import { connect } from 'react-redux';
|
2021-07-29 16:53:36 +02:00
|
|
|
import {
|
2021-10-13 22:28:19 +02:00
|
|
|
doResolveUris,
|
2021-07-29 16:53:36 +02:00
|
|
|
makeSelectClaimForUri,
|
|
|
|
makeSelectClaimIsMine,
|
|
|
|
selectFetchingMyChannels,
|
|
|
|
selectMyChannelClaims,
|
2021-10-17 10:36:14 +02:00
|
|
|
} from 'redux/selectors/claims';
|
2020-09-30 20:46:17 +02:00
|
|
|
import {
|
|
|
|
makeSelectTopLevelCommentsForUri,
|
2021-07-15 16:43:28 +02:00
|
|
|
makeSelectTopLevelTotalPagesForUri,
|
2020-09-30 20:46:17 +02:00
|
|
|
selectIsFetchingComments,
|
2021-10-01 09:49:37 +02:00
|
|
|
selectIsFetchingCommentsById,
|
2021-07-15 18:13:01 +02:00
|
|
|
selectIsFetchingReacts,
|
2020-09-30 20:46:17 +02:00
|
|
|
makeSelectTotalCommentsCountForUri,
|
2020-10-06 21:35:13 +02:00
|
|
|
selectOthersReactsById,
|
2021-07-15 16:43:28 +02:00
|
|
|
selectMyReactionsByCommentId,
|
|
|
|
makeSelectCommentIdsForUri,
|
2021-07-29 16:53:36 +02:00
|
|
|
selectSettingsByChannelId,
|
2021-08-17 18:09:55 +02:00
|
|
|
makeSelectPinnedCommentsForUri,
|
2020-09-30 20:46:17 +02:00
|
|
|
} from 'redux/selectors/comments';
|
2021-07-15 16:43:28 +02:00
|
|
|
import { doCommentReset, doCommentList, doCommentById, doCommentReactList } from 'redux/actions/comments';
|
2021-07-20 08:38:29 +02:00
|
|
|
import { selectActiveChannelClaim } from 'redux/selectors/app';
|
2020-10-20 19:10:02 +02:00
|
|
|
import CommentsList from './view';
|
2019-05-17 20:21:07 +02:00
|
|
|
|
2021-07-15 16:43:28 +02:00
|
|
|
const select = (state, props) => {
|
2021-07-20 08:38:29 +02:00
|
|
|
const activeChannelClaim = selectActiveChannelClaim(state);
|
2021-10-13 22:28:19 +02:00
|
|
|
const topLevelComments = makeSelectTopLevelCommentsForUri(props.uri)(state);
|
|
|
|
|
2021-10-14 13:24:21 +02:00
|
|
|
const resolvedComments =
|
|
|
|
topLevelComments && topLevelComments.length > 0
|
|
|
|
? topLevelComments.filter(({ channel_url }) => makeSelectClaimForUri(channel_url)(state) !== undefined)
|
|
|
|
: [];
|
2021-10-13 22:28:19 +02:00
|
|
|
|
2021-07-15 16:43:28 +02:00
|
|
|
return {
|
2021-10-13 22:28:19 +02:00
|
|
|
topLevelComments,
|
|
|
|
resolvedComments,
|
2021-07-15 16:43:28 +02:00
|
|
|
myChannels: selectMyChannelClaims(state),
|
|
|
|
allCommentIds: makeSelectCommentIdsForUri(props.uri)(state),
|
2021-08-17 18:09:55 +02:00
|
|
|
pinnedComments: makeSelectPinnedCommentsForUri(props.uri)(state),
|
2021-07-15 16:43:28 +02:00
|
|
|
topLevelTotalPages: makeSelectTopLevelTotalPagesForUri(props.uri)(state),
|
|
|
|
totalComments: makeSelectTotalCommentsCountForUri(props.uri)(state),
|
2021-07-29 16:53:36 +02:00
|
|
|
claim: makeSelectClaimForUri(props.uri)(state),
|
2021-07-15 16:43:28 +02:00
|
|
|
claimIsMine: makeSelectClaimIsMine(props.uri)(state),
|
|
|
|
isFetchingComments: selectIsFetchingComments(state),
|
2021-10-01 09:49:37 +02:00
|
|
|
isFetchingCommentsById: selectIsFetchingCommentsById(state),
|
2021-07-15 18:13:01 +02:00
|
|
|
isFetchingReacts: selectIsFetchingReacts(state),
|
2021-07-15 16:43:28 +02:00
|
|
|
fetchingChannels: selectFetchingMyChannels(state),
|
2021-07-29 16:53:36 +02:00
|
|
|
settingsByChannelId: selectSettingsByChannelId(state),
|
2021-07-15 16:43:28 +02:00
|
|
|
myReactsByCommentId: selectMyReactionsByCommentId(state),
|
|
|
|
othersReactsById: selectOthersReactsById(state),
|
2021-07-20 08:38:29 +02:00
|
|
|
activeChannelId: activeChannelClaim && activeChannelClaim.claim_id,
|
2021-07-15 16:43:28 +02:00
|
|
|
};
|
|
|
|
};
|
2019-05-17 20:21:07 +02:00
|
|
|
|
2021-06-03 07:57:50 +02:00
|
|
|
const perform = (dispatch) => ({
|
2021-07-15 16:43:28 +02:00
|
|
|
fetchTopLevelComments: (uri, page, pageSize, sortBy) => dispatch(doCommentList(uri, '', page, pageSize, sortBy)),
|
|
|
|
fetchComment: (commentId) => dispatch(doCommentById(commentId)),
|
|
|
|
fetchReacts: (commentIds) => dispatch(doCommentReactList(commentIds)),
|
2021-10-01 14:10:27 +02:00
|
|
|
resetComments: (claimId) => dispatch(doCommentReset(claimId)),
|
2021-10-13 22:28:19 +02:00
|
|
|
doResolveUris: (uris) => dispatch(doResolveUris(uris, true)),
|
2019-05-17 20:21:07 +02:00
|
|
|
});
|
2019-06-27 01:59:27 +02:00
|
|
|
|
2020-01-30 02:02:21 +01:00
|
|
|
export default connect(select, perform)(CommentsList);
|