2020-09-11 19:51:31 +02:00
|
|
|
import { connect } from 'react-redux';
|
|
|
|
import Comment from './view';
|
2020-10-27 17:24:31 +01:00
|
|
|
import { makeSelectClaimIsMine, makeSelectClaimForUri } from 'lbry-redux';
|
2020-12-14 22:42:00 +01:00
|
|
|
import { doToast } from 'redux/actions/notifications';
|
2021-02-09 17:05:56 +01:00
|
|
|
import { makeSelectMyReactionsForComment, makeSelectOthersReactionsForComment } from 'redux/selectors/comments';
|
2020-09-29 16:10:23 +02:00
|
|
|
import { doCommentReact } from 'redux/actions/comments';
|
2021-07-20 08:38:29 +02:00
|
|
|
import { selectActiveChannelClaim } from 'redux/selectors/app';
|
2020-09-11 19:51:31 +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);
|
|
|
|
const activeChannelId = activeChannelClaim && activeChannelClaim.claim_id;
|
2021-07-15 16:43:28 +02:00
|
|
|
const reactionKey = activeChannelId ? `${props.commentId}:${activeChannelId}` : props.commentId;
|
|
|
|
|
|
|
|
return {
|
|
|
|
claim: makeSelectClaimForUri(props.uri)(state),
|
|
|
|
claimIsMine: makeSelectClaimIsMine(props.uri)(state),
|
|
|
|
myReacts: makeSelectMyReactionsForComment(reactionKey)(state),
|
|
|
|
othersReacts: makeSelectOthersReactionsForComment(reactionKey)(state),
|
|
|
|
activeChannelId,
|
|
|
|
};
|
|
|
|
};
|
2020-09-11 19:51:31 +02:00
|
|
|
|
2021-07-15 16:43:28 +02:00
|
|
|
const perform = (dispatch) => ({
|
2020-09-29 16:10:23 +02:00
|
|
|
react: (commentId, type) => dispatch(doCommentReact(commentId, type)),
|
2021-07-15 16:43:28 +02:00
|
|
|
doToast: (params) => dispatch(doToast(params)),
|
2020-09-29 16:10:23 +02:00
|
|
|
});
|
2020-09-11 19:51:31 +02:00
|
|
|
|
|
|
|
export default connect(select, perform)(Comment);
|