2020-10-02 21:18:53 +02:00
|
|
|
import { connect } from 'react-redux';
|
|
|
|
import {
|
|
|
|
makeSelectMyReactionForUri,
|
|
|
|
makeSelectLikeCountForUri,
|
|
|
|
makeSelectDislikeCountForUri,
|
|
|
|
} from 'redux/selectors/reactions';
|
|
|
|
import { doFetchReactions, doReactionLike, doReactionDislike } from 'redux/actions/reactions';
|
2022-02-02 13:45:16 +01:00
|
|
|
import FileReactions from './view';
|
2022-02-01 21:07:08 +01:00
|
|
|
import { selectClaimForUri, selectIsStreamPlaceholderForUri } from 'redux/selectors/claims';
|
2020-10-02 21:18:53 +02:00
|
|
|
|
2022-02-01 21:07:08 +01:00
|
|
|
const select = (state, props) => {
|
|
|
|
const { uri } = props;
|
2020-10-02 21:18:53 +02:00
|
|
|
|
2022-02-01 21:07:08 +01:00
|
|
|
const claim = selectClaimForUri(state, uri);
|
|
|
|
const { claim_id: claimId, signing_channel, value_type } = claim || {};
|
|
|
|
|
2022-04-15 10:56:50 +02:00
|
|
|
let channelTitle = null;
|
|
|
|
if (signing_channel) {
|
|
|
|
const { value, name } = signing_channel;
|
|
|
|
if (value && value.title) {
|
|
|
|
channelTitle = value.title;
|
|
|
|
} else {
|
|
|
|
channelTitle = name;
|
|
|
|
}
|
|
|
|
}
|
2022-02-01 21:07:08 +01:00
|
|
|
const isCollection = value_type && value_type === 'collection'; // hack because nudge gets cut off by card on cols.
|
|
|
|
|
|
|
|
return {
|
|
|
|
myReaction: makeSelectMyReactionForUri(uri)(state),
|
|
|
|
likeCount: makeSelectLikeCountForUri(uri)(state),
|
|
|
|
dislikeCount: makeSelectDislikeCountForUri(uri)(state),
|
|
|
|
isLivestreamClaim: selectIsStreamPlaceholderForUri(state, uri),
|
|
|
|
claimId,
|
2022-04-15 10:56:50 +02:00
|
|
|
channelTitle,
|
2022-02-01 21:07:08 +01:00
|
|
|
isCollection,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
const perform = {
|
2020-10-02 21:18:53 +02:00
|
|
|
doFetchReactions,
|
|
|
|
doReactionLike,
|
|
|
|
doReactionDislike,
|
2022-02-01 21:07:08 +01:00
|
|
|
};
|
|
|
|
|
2022-02-02 13:45:16 +01:00
|
|
|
export default connect(select, perform)(FileReactions);
|