2017-12-21 22:08:54 +01:00
|
|
|
import { connect } from 'react-redux';
|
2020-04-23 18:44:18 +02:00
|
|
|
import {
|
2021-11-16 05:23:18 +01:00
|
|
|
selectTitleForUri,
|
2022-02-02 17:20:10 +01:00
|
|
|
selectClaimForUri,
|
2021-11-10 03:30:03 +01:00
|
|
|
selectClaimIsMineForUri,
|
2020-06-15 16:04:44 +02:00
|
|
|
selectFetchingMyChannels,
|
2021-10-17 10:36:14 +02:00
|
|
|
} from 'redux/selectors/claims';
|
2021-10-28 22:25:34 +02:00
|
|
|
import { doHideModal } from 'redux/actions/app';
|
|
|
|
import { doSendTip, doSendCashTip } from 'redux/actions/wallet';
|
2021-11-23 05:29:04 +01:00
|
|
|
import { selectClientSetting } from 'redux/selectors/settings';
|
2021-10-28 22:25:34 +02:00
|
|
|
import { selectActiveChannelClaim, selectIncognito } from 'redux/selectors/app';
|
2021-10-17 10:36:14 +02:00
|
|
|
import { selectBalance, selectIsSendingSupport } from 'redux/selectors/wallet';
|
2021-10-28 22:25:34 +02:00
|
|
|
import { withRouter } from 'react-router';
|
2021-10-17 10:36:14 +02:00
|
|
|
import * as SETTINGS from 'constants/settings';
|
2022-02-02 17:20:10 +01:00
|
|
|
import { getChannelIdFromClaim, getChannelNameFromClaim } from 'util/claim';
|
2018-04-04 01:58:58 +02:00
|
|
|
import WalletSendTip from './view';
|
2017-09-17 22:33:52 +02:00
|
|
|
|
2022-02-02 17:20:10 +01:00
|
|
|
const select = (state, props) => {
|
|
|
|
const { uri } = props;
|
2017-09-17 22:33:52 +02:00
|
|
|
|
2022-02-02 17:20:10 +01:00
|
|
|
const claim = selectClaimForUri(state, uri, false);
|
|
|
|
const { claim_id: claimId, value_type: claimType } = claim || {};
|
|
|
|
|
|
|
|
// setup variables for backend tip API
|
|
|
|
const channelClaimId = getChannelIdFromClaim(claim);
|
|
|
|
const tipChannelName = getChannelNameFromClaim(claim);
|
|
|
|
|
|
|
|
const activeChannelClaim = selectActiveChannelClaim(state);
|
|
|
|
const { name: activeChannelName, claim_id: activeChannelId } = activeChannelClaim || {};
|
|
|
|
|
|
|
|
return {
|
|
|
|
activeChannelName,
|
|
|
|
activeChannelId,
|
|
|
|
balance: selectBalance(state),
|
|
|
|
claimId,
|
|
|
|
claimType,
|
|
|
|
channelClaimId,
|
|
|
|
tipChannelName,
|
|
|
|
claimIsMine: selectClaimIsMineForUri(state, uri),
|
|
|
|
fetchingChannels: selectFetchingMyChannels(state),
|
|
|
|
incognito: selectIncognito(state),
|
|
|
|
instantTipEnabled: selectClientSetting(state, SETTINGS.INSTANT_PURCHASE_ENABLED),
|
|
|
|
instantTipMax: selectClientSetting(state, SETTINGS.INSTANT_PURCHASE_MAX),
|
|
|
|
isPending: selectIsSendingSupport(state),
|
|
|
|
title: selectTitleForUri(state, uri),
|
2022-03-28 23:40:56 +02:00
|
|
|
preferredCurrency: selectClientSetting(state, SETTINGS.PREFERRED_CURRENCY),
|
2022-02-02 17:20:10 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
const perform = {
|
|
|
|
doHideModal,
|
|
|
|
doSendTip,
|
|
|
|
doSendCashTip,
|
|
|
|
};
|
|
|
|
|
|
|
|
export default withRouter(connect(select, perform)(WalletSendTip));
|