2020-09-11 13:51:31 -04:00
|
|
|
import { connect } from 'react-redux';
|
|
|
|
import Comment from './view';
|
2021-12-31 12:52:26 -05:00
|
|
|
import { selectClaimIsMine, selectClaimForUri } from 'redux/selectors/claims';
|
2021-10-07 23:47:39 -04:00
|
|
|
import { doResolveUri } from 'redux/actions/claims';
|
2020-12-14 16:42:00 -05:00
|
|
|
import { doToast } from 'redux/actions/notifications';
|
2021-10-07 02:40:40 +08:00
|
|
|
import { selectMyReactsForComment, selectOthersReactsForComment } from 'redux/selectors/comments';
|
2020-09-29 10:10:23 -04:00
|
|
|
import { doCommentReact } from 'redux/actions/comments';
|
2021-07-20 14:38:29 +08:00
|
|
|
import { selectActiveChannelClaim } from 'redux/selectors/app';
|
2020-09-11 13:51:31 -04:00
|
|
|
|
2021-07-15 22:43:28 +08:00
|
|
|
const select = (state, props) => {
|
2021-07-20 14:38:29 +08:00
|
|
|
const activeChannelClaim = selectActiveChannelClaim(state);
|
|
|
|
const activeChannelId = activeChannelClaim && activeChannelClaim.claim_id;
|
2021-07-15 22:43:28 +08:00
|
|
|
const reactionKey = activeChannelId ? `${props.commentId}:${activeChannelId}` : props.commentId;
|
2021-12-31 12:52:26 -05:00
|
|
|
const claim = selectClaimForUri(state, props.uri);
|
2021-07-15 22:43:28 +08:00
|
|
|
|
|
|
|
return {
|
2021-12-31 12:52:26 -05:00
|
|
|
claim,
|
|
|
|
claimIsMine: selectClaimIsMine(state, claim),
|
2021-10-07 02:40:40 +08:00
|
|
|
myReacts: selectMyReactsForComment(state, reactionKey),
|
|
|
|
othersReacts: selectOthersReactsForComment(state, reactionKey),
|
2021-07-15 22:43:28 +08:00
|
|
|
activeChannelId,
|
|
|
|
};
|
|
|
|
};
|
2020-09-11 13:51:31 -04:00
|
|
|
|
2021-07-15 22:43:28 +08:00
|
|
|
const perform = (dispatch) => ({
|
2021-09-01 13:03:48 -03:00
|
|
|
resolve: (uri) => dispatch(doResolveUri(uri)),
|
2020-09-29 10:10:23 -04:00
|
|
|
react: (commentId, type) => dispatch(doCommentReact(commentId, type)),
|
2021-07-15 22:43:28 +08:00
|
|
|
doToast: (params) => dispatch(doToast(params)),
|
2020-09-29 10:10:23 -04:00
|
|
|
});
|
2020-09-11 13:51:31 -04:00
|
|
|
|
|
|
|
export default connect(select, perform)(Comment);
|