61 lines
2.1 KiB
JavaScript
61 lines
2.1 KiB
JavaScript
import { connect } from 'react-redux';
|
|
import {
|
|
selectClaimForUri,
|
|
selectClaimIsMine,
|
|
selectHasChannels,
|
|
selectFetchingMyChannels,
|
|
makeSelectTagInClaimOrChannelForUri,
|
|
} from 'redux/selectors/claims';
|
|
import { CommentCreate } from './view';
|
|
import { DISABLE_SUPPORT_TAG } from 'constants/tags';
|
|
import { doCommentCreate, doFetchCreatorSettings, doCommentById } from 'redux/actions/comments';
|
|
import { doSendTip, doSendCashTip } from 'redux/actions/wallet';
|
|
import { doToast } from 'redux/actions/notifications';
|
|
import { selectActiveChannelClaim } from 'redux/selectors/app';
|
|
import { selectSettingsByChannelId } from 'redux/selectors/comments';
|
|
import { getChannelIdFromClaim } from 'util/claim';
|
|
import { doOpenModal } from 'redux/actions/app';
|
|
import { selectClientSetting } from 'redux/selectors/settings';
|
|
import * as SETTINGS from 'constants/settings';
|
|
|
|
const select = (state, props) => {
|
|
const { uri } = props;
|
|
|
|
const claim = selectClaimForUri(state, uri);
|
|
const { claim_id: claimId, name, signing_channel: channel } = claim || {};
|
|
|
|
// setup variables for tip API
|
|
const channelClaimId = getChannelIdFromClaim(claim);
|
|
const tipChannelName = channel ? channel.name : name;
|
|
|
|
const activeChannelClaim = selectActiveChannelClaim(state);
|
|
const { claim_id: activeChannelClaimId, name: activeChannelName, canonical_url: activeChannelUrl } =
|
|
activeChannelClaim || {};
|
|
|
|
return {
|
|
activeChannelClaimId,
|
|
activeChannelName,
|
|
activeChannelUrl,
|
|
hasChannels: selectHasChannels(state),
|
|
claimId,
|
|
channelClaimId,
|
|
tipChannelName,
|
|
claimIsMine: selectClaimIsMine(state, claim),
|
|
isFetchingChannels: selectFetchingMyChannels(state),
|
|
settingsByChannelId: selectSettingsByChannelId(state),
|
|
supportDisabled: makeSelectTagInClaimOrChannelForUri(uri, DISABLE_SUPPORT_TAG)(state),
|
|
preferredCurrency: selectClientSetting(state, SETTINGS.PREFERRED_CURRENCY),
|
|
};
|
|
};
|
|
|
|
const perform = {
|
|
doCommentCreate,
|
|
doFetchCreatorSettings,
|
|
doToast,
|
|
doCommentById,
|
|
doSendCashTip,
|
|
doSendTip,
|
|
doOpenModal,
|
|
};
|
|
|
|
export default connect(select, perform)(CommentCreate);
|