lbry-desktop/ui/component/commentReactions/index.js
infinite-persistence 08738ffcee
Reaction-fetch: handle "deleted all channels"
- use `selectActiveChannelClaim` as that takes the current channel list into account (i.e. correct state when all channels are deleted).
    - `selectActiveChannelId` should probably be removed or not exposed through a selector, as it is not updated when channel list changes?
2021-07-20 15:22:50 +08:00

29 lines
1.2 KiB
JavaScript

import { connect } from 'react-redux';
import Comment from './view';
import { makeSelectClaimIsMine, makeSelectClaimForUri } from 'lbry-redux';
import { doToast } from 'redux/actions/notifications';
import { makeSelectMyReactionsForComment, makeSelectOthersReactionsForComment } from 'redux/selectors/comments';
import { doCommentReact } from 'redux/actions/comments';
import { selectActiveChannelClaim } from 'redux/selectors/app';
const select = (state, props) => {
const activeChannelClaim = selectActiveChannelClaim(state);
const activeChannelId = activeChannelClaim && activeChannelClaim.claim_id;
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,
};
};
const perform = (dispatch) => ({
react: (commentId, type) => dispatch(doCommentReact(commentId, type)),
doToast: (params) => dispatch(doToast(params)),
});
export default connect(select, perform)(Comment);