Use "Purchase and Tip Confirmations" setting to determine if a confirmation dialog is needed for tipping.

This commit is contained in:
Jeffrey Fisher 2020-04-24 16:53:57 -07:00 committed by Sean Yesmunt
parent cb470ad970
commit 122781036d
4 changed files with 50 additions and 16 deletions

View file

@ -179,10 +179,10 @@
"No Limit": "No Limit",
"Choose limit": "Choose limit",
"This will prevent you from purchasing any content over a certain cost, as a safety measure.": "This will prevent you from purchasing any content over a certain cost, as a safety measure.",
"Purchase Confirmations": "Purchase Confirmations",
"Always confirm before purchasing content": "Always confirm before purchasing content",
"Only confirm purchases over a certain price": "Only confirm purchases over a certain price",
"When this option is chosen, LBRY won't ask you to confirm downloads below your chosen price.": "When this option is chosen, LBRY won't ask you to confirm downloads below your chosen price.",
"Purchase and Tip Confirmations": "Purchase and Tip Confirmations",
"Always confirm before purchasing content or tipping": "Always confirm before purchasing content or tipping",
"Only confirm purchases or tips over a certain amount": "Only confirm purchases or tips over a certain amount",
"When this option is chosen, LBRY won't ask you to confirm downloads or tips below your chosen amount.": "When this option is chosen, LBRY won't ask you to confirm downloads or tips below your chosen amount.",
"Content Settings": "Content Settings",
"Show NSFW content": "Show NSFW content",
"NSFW content may include nudity, intense sexuality, profanity, or other adult content. By displaying NSFW content, you are affirming you are of legal age to view mature content in your country or jurisdiction. ": "NSFW content may include nudity, intense sexuality, profanity, or other adult content. By displaying NSFW content, you are affirming you are of legal age to view mature content in your country or jurisdiction. ",

View file

@ -5,16 +5,20 @@ import {
makeSelectClaimForUri,
selectIsSendingSupport,
selectBalance,
SETTINGS,
} from 'lbry-redux';
import WalletSendTip from './view';
import { doOpenModal } from 'redux/actions/app';
import { withRouter } from 'react-router';
import { makeSelectClientSetting } from 'redux/selectors/settings';
const select = (state, props) => ({
isPending: selectIsSendingSupport(state),
title: makeSelectTitleForUri(props.uri)(state),
claim: makeSelectClaimForUri(props.uri, false)(state),
balance: selectBalance(state),
instantTipEnabled: makeSelectClientSetting(SETTINGS.INSTANT_PURCHASE_ENABLED)(state),
instantTipMax: makeSelectClientSetting(SETTINGS.INSTANT_PURCHASE_MAX)(state),
});
const perform = dispatch => ({

View file

@ -7,6 +7,7 @@ import useIsMobile from 'effects/use-is-mobile';
import CreditAmount from 'component/common/credit-amount';
import I18nMessage from 'component/i18nMessage';
import * as MODALS from 'constants/modal_types';
import { Lbryio } from 'lbryinc';
type Props = {
uri: string,
@ -20,24 +21,51 @@ type Props = {
balance: number,
isSupport: boolean,
openModal: (id: string, { tipAmount: number, claimId: string, isSupport: boolean }) => void,
instantTipEnabled: boolean,
instantTipMax: { amount: number, currency: string },
};
function WalletSendTip(props: Props) {
const { title, isPending, onCancel, claimIsMine, isSupport, balance, claim } = props;
const {
title,
isPending,
onCancel,
claimIsMine,
isSupport,
balance,
claim,
instantTipEnabled,
instantTipMax,
openModal,
sendSupport,
} = props;
const [tipAmount, setTipAmount] = React.useState(0);
const [tipError, setTipError] = React.useState();
const { claim_id: claimId } = claim;
const isMobile = useIsMobile();
function handleSubmit() {
const { openModal, sendSupport } = props;
function sendSupportOrConfirm(instantTipMaxAmount = null) {
if (!isSupport && (!instantTipMaxAmount || !instantTipEnabled || tipAmount > instantTipMaxAmount)) {
const modalProps = { tipAmount, claimId, title, isSupport };
openModal(MODALS.CONFIRM_SEND_TIP, modalProps);
} else {
sendSupport(tipAmount, claimId, isSupport);
}
}
function handleSubmit() {
if (tipAmount && claimId) {
if (isSupport) {
sendSupport(tipAmount, claimId, isSupport);
if (instantTipEnabled) {
if (instantTipMax.currency === 'LBC') {
sendSupportOrConfirm(instantTipMax.amount);
} else {
// Need to convert currency of instant purchase maximum before trying to send support
Lbryio.getExchangeRates().then(({ LBC_USD }) => {
sendSupportOrConfirm(instantTipMax.amount / LBC_USD);
});
}
} else {
const modalProps = { tipAmount, claimId, title, isSupport };
openModal(MODALS.CONFIRM_SEND_TIP, modalProps);
sendSupportOrConfirm();
}
}
}

View file

@ -367,15 +367,16 @@ class SettingsPage extends React.PureComponent<Props, State> {
}
/>
{/* @endif */}
<Card
title={__('Purchase Confirmations')}
title={__('Purchase and Tip Confirmations')}
actions={
<React.Fragment>
<FormField
type="radio"
name="confirm_all_purchases"
checked={!instantPurchaseEnabled}
label={__('Always confirm before purchasing content')}
label={__('Always confirm before purchasing content or tipping')}
onChange={() => {
this.onInstantPurchaseEnabledChange(false);
}}
@ -384,7 +385,7 @@ class SettingsPage extends React.PureComponent<Props, State> {
type="radio"
name="instant_purchases"
checked={instantPurchaseEnabled}
label={__('Only confirm purchases over a certain price')}
label={__('Only confirm purchases or tips over a certain amount')}
onChange={() => {
this.onInstantPurchaseEnabledChange(true);
}}
@ -400,13 +401,14 @@ class SettingsPage extends React.PureComponent<Props, State> {
)}
<p className="help">
{__("When this option is chosen, LBRY won't ask you to confirm downloads below your chosen price.")}
{__(
"When this option is chosen, LBRY won't ask you to confirm downloads or tips below your chosen amount."
)}
</p>
</React.Fragment>
}
/>
{/* @endif */}
<Card
title={__('Content Settings')}
actions={