diff --git a/static/app-strings.json b/static/app-strings.json index 1f659dcc9..b367b61b1 100644 --- a/static/app-strings.json +++ b/static/app-strings.json @@ -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. ", diff --git a/ui/component/walletSendTip/index.js b/ui/component/walletSendTip/index.js index feff1aa0b..4fe81d18e 100644 --- a/ui/component/walletSendTip/index.js +++ b/ui/component/walletSendTip/index.js @@ -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 => ({ diff --git a/ui/component/walletSendTip/view.jsx b/ui/component/walletSendTip/view.jsx index 4a4fdb3bf..600b3cf1c 100644 --- a/ui/component/walletSendTip/view.jsx +++ b/ui/component/walletSendTip/view.jsx @@ -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(); } } } diff --git a/ui/page/settings/view.jsx b/ui/page/settings/view.jsx index 4404b7579..7f32be184 100644 --- a/ui/page/settings/view.jsx +++ b/ui/page/settings/view.jsx @@ -367,15 +367,16 @@ class SettingsPage extends React.PureComponent { } /> + {/* @endif */} { this.onInstantPurchaseEnabledChange(false); }} @@ -384,7 +385,7 @@ class SettingsPage extends React.PureComponent { 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 { )}

- {__("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." + )}

} /> - {/* @endif */}