import { connect } from 'react-redux'; import { selectClaimForUri, selectClaimIsMine, selectHasChannels, selectFetchingMyChannels, makeSelectTagInClaimOrChannelForUri, selectMyChannelClaimIds, } from 'redux/selectors/claims'; import { CommentCreate } from './view'; import { DISABLE_SUPPORT_TAG } from 'constants/tags'; import { doCommentCreate, doFetchCreatorSettings, doCommentById, doFetchMyCommentedChannels, } from 'redux/actions/comments'; import { doSendTip, doSendCashTip } from 'redux/actions/wallet'; import { doToast } from 'redux/actions/notifications'; import { selectActiveChannelClaim } from 'redux/selectors/app'; import { selectMyCommentedChannelIdsForId, 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), myChannelClaimIds: selectMyChannelClaimIds(state), myCommentedChannelIds: selectMyCommentedChannelIdsForId(state, claim?.claim_id), }; }; const perform = { doCommentCreate, doFetchCreatorSettings, doFetchMyCommentedChannels, doToast, doCommentById, doSendCashTip, doSendTip, doOpenModal, }; export default connect(select, perform)(CommentCreate);