2019-05-17 14:21:07 -04:00
|
|
|
import { connect } from 'react-redux';
|
2021-10-17 16:54:57 +08:00
|
|
|
import { doResolveUris } from 'redux/actions/claims';
|
2021-07-29 22:53:36 +08:00
|
|
|
import {
|
2021-11-11 12:48:10 +08:00
|
|
|
selectClaimForUri,
|
2021-07-29 22:53:36 +08:00
|
|
|
makeSelectClaimForUri,
|
2021-11-11 12:48:10 +08:00
|
|
|
selectClaimIsMine,
|
2021-07-29 22:53:36 +08:00
|
|
|
selectFetchingMyChannels,
|
2021-11-04 13:26:11 +08:00
|
|
|
selectMyClaimIdsRaw,
|
2021-10-17 16:36:14 +08:00
|
|
|
} from 'redux/selectors/claims';
|
2020-09-30 14:46:17 -04:00
|
|
|
import {
|
2021-10-11 14:02:17 +08:00
|
|
|
selectTopLevelCommentsForUri,
|
2021-07-15 22:43:28 +08:00
|
|
|
makeSelectTopLevelTotalPagesForUri,
|
2020-09-30 14:46:17 -04:00
|
|
|
selectIsFetchingComments,
|
2021-10-01 15:49:37 +08:00
|
|
|
selectIsFetchingCommentsById,
|
2021-07-16 00:13:01 +08:00
|
|
|
selectIsFetchingReacts,
|
2020-09-30 14:46:17 -04:00
|
|
|
makeSelectTotalCommentsCountForUri,
|
2021-10-07 02:40:40 +08:00
|
|
|
selectOthersReacts,
|
|
|
|
selectMyReacts,
|
2021-11-09 23:32:16 +08:00
|
|
|
selectCommentIdsForUri,
|
2021-07-29 22:53:36 +08:00
|
|
|
selectSettingsByChannelId,
|
2021-10-11 14:02:17 +08:00
|
|
|
selectPinnedCommentsForUri,
|
2020-09-30 14:46:17 -04:00
|
|
|
} from 'redux/selectors/comments';
|
2021-07-15 22:43:28 +08:00
|
|
|
import { doCommentReset, doCommentList, doCommentById, doCommentReactList } from 'redux/actions/comments';
|
2021-07-20 14:38:29 +08:00
|
|
|
import { selectActiveChannelClaim } from 'redux/selectors/app';
|
2020-10-20 13:10:02 -04:00
|
|
|
import CommentsList from './view';
|
2019-05-17 14:21:07 -04:00
|
|
|
|
2021-07-15 22:43:28 +08:00
|
|
|
const select = (state, props) => {
|
2021-11-11 12:48:10 +08:00
|
|
|
const claim = selectClaimForUri(state, props.uri);
|
2021-07-20 14:38:29 +08:00
|
|
|
const activeChannelClaim = selectActiveChannelClaim(state);
|
2021-10-11 14:02:17 +08:00
|
|
|
const topLevelComments = selectTopLevelCommentsForUri(state, props.uri);
|
2021-10-13 17:28:19 -03:00
|
|
|
|
2021-10-14 08:24:21 -03:00
|
|
|
const resolvedComments =
|
|
|
|
topLevelComments && topLevelComments.length > 0
|
|
|
|
? topLevelComments.filter(({ channel_url }) => makeSelectClaimForUri(channel_url)(state) !== undefined)
|
|
|
|
: [];
|
2021-10-13 17:28:19 -03:00
|
|
|
|
2021-07-15 22:43:28 +08:00
|
|
|
return {
|
2021-10-13 17:28:19 -03:00
|
|
|
topLevelComments,
|
|
|
|
resolvedComments,
|
2021-11-04 13:26:11 +08:00
|
|
|
myChannelIds: selectMyClaimIdsRaw(state),
|
2021-11-09 23:32:16 +08:00
|
|
|
allCommentIds: selectCommentIdsForUri(state, props.uri),
|
2021-10-11 14:02:17 +08:00
|
|
|
pinnedComments: selectPinnedCommentsForUri(state, props.uri),
|
2021-07-15 22:43:28 +08:00
|
|
|
topLevelTotalPages: makeSelectTopLevelTotalPagesForUri(props.uri)(state),
|
|
|
|
totalComments: makeSelectTotalCommentsCountForUri(props.uri)(state),
|
2021-11-11 12:48:10 +08:00
|
|
|
claim,
|
|
|
|
claimIsMine: selectClaimIsMine(state, claim),
|
2021-07-15 22:43:28 +08:00
|
|
|
isFetchingComments: selectIsFetchingComments(state),
|
2021-10-01 15:49:37 +08:00
|
|
|
isFetchingCommentsById: selectIsFetchingCommentsById(state),
|
2021-07-16 00:13:01 +08:00
|
|
|
isFetchingReacts: selectIsFetchingReacts(state),
|
2021-07-15 22:43:28 +08:00
|
|
|
fetchingChannels: selectFetchingMyChannels(state),
|
2021-07-29 22:53:36 +08:00
|
|
|
settingsByChannelId: selectSettingsByChannelId(state),
|
2021-10-07 02:40:40 +08:00
|
|
|
myReactsByCommentId: selectMyReacts(state),
|
|
|
|
othersReactsById: selectOthersReacts(state),
|
2021-07-20 14:38:29 +08:00
|
|
|
activeChannelId: activeChannelClaim && activeChannelClaim.claim_id,
|
2021-07-15 22:43:28 +08:00
|
|
|
};
|
|
|
|
};
|
2019-05-17 14:21:07 -04:00
|
|
|
|
2021-06-03 13:57:50 +08:00
|
|
|
const perform = (dispatch) => ({
|
2021-07-15 22:43:28 +08: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 20:10:27 +08:00
|
|
|
resetComments: (claimId) => dispatch(doCommentReset(claimId)),
|
2021-10-13 17:28:19 -03:00
|
|
|
doResolveUris: (uris) => dispatch(doResolveUris(uris, true)),
|
2019-05-17 14:21:07 -04:00
|
|
|
});
|
2019-06-26 19:59:27 -04:00
|
|
|
|
2020-01-29 20:02:21 -05:00
|
|
|
export default connect(select, perform)(CommentsList);
|