[Content] grab "Purchase and tip confirmations"

This commit is contained in:
infinite-persistence 2021-08-07 20:40:17 +08:00
parent 502ab6f6a9
commit f7caeba787
No known key found for this signature in database
GPG key ID: B9C3252EDC3D0AA0
4 changed files with 41 additions and 58 deletions

View file

@ -14,6 +14,8 @@ const select = (state) => ({
hideReposts: makeSelectClientSetting(SETTINGS.HIDE_REPOSTS)(state), hideReposts: makeSelectClientSetting(SETTINGS.HIDE_REPOSTS)(state),
showNsfw: selectShowMatureContent(state), showNsfw: selectShowMatureContent(state),
myChannelUrls: selectMyChannelUrls(state), myChannelUrls: selectMyChannelUrls(state),
instantPurchaseEnabled: makeSelectClientSetting(SETTINGS.INSTANT_PURCHASE_ENABLED)(state),
instantPurchaseMax: makeSelectClientSetting(SETTINGS.INSTANT_PURCHASE_MAX)(state),
}); });
const perform = (dispatch) => ({ const perform = (dispatch) => ({

View file

@ -8,10 +8,15 @@ import { SIMPLE_SITE } from 'config';
import * as MODALS from 'constants/modal_types'; import * as MODALS from 'constants/modal_types';
import Button from 'component/button'; import Button from 'component/button';
import Card from 'component/common/card'; import Card from 'component/common/card';
import { FormField } from 'component/common/form'; import { FormField, FormFieldPrice } from 'component/common/form';
import MaxPurchasePrice from 'component/maxPurchasePrice'; import MaxPurchasePrice from 'component/maxPurchasePrice';
import SettingsRow from 'component/settingsRow'; import SettingsRow from 'component/settingsRow';
type Price = {
currency: string,
amount: number,
};
type Props = { type Props = {
isAuthenticated: boolean, isAuthenticated: boolean,
floatingPlayer: boolean, floatingPlayer: boolean,
@ -19,6 +24,8 @@ type Props = {
hideReposts: ?boolean, hideReposts: ?boolean,
showNsfw: boolean, showNsfw: boolean,
myChannelUrls: ?Array<string>, myChannelUrls: ?Array<string>,
instantPurchaseEnabled: boolean,
instantPurchaseMax: Price,
setClientSetting: (string, boolean | string | number) => void, setClientSetting: (string, boolean | string | number) => void,
clearPlayingUri: () => void, clearPlayingUri: () => void,
openModal: (string) => void, openModal: (string) => void,
@ -32,6 +39,8 @@ export default function SettingContent(props: Props) {
hideReposts, hideReposts,
showNsfw, showNsfw,
myChannelUrls, myChannelUrls,
instantPurchaseEnabled,
instantPurchaseMax,
setClientSetting, setClientSetting,
clearPlayingUri, clearPlayingUri,
openModal, openModal,
@ -145,6 +154,32 @@ export default function SettingContent(props: Props) {
<MaxPurchasePrice /> <MaxPurchasePrice />
</SettingsRow> </SettingsRow>
{/* @endif */} {/* @endif */}
<SettingsRow title={__('Purchase and tip confirmations')} useVerticalSeparator>
<FormField
type="radio"
name="confirm_all_purchases"
checked={!instantPurchaseEnabled}
label={__('Always confirm before purchasing content or tipping')}
onChange={() => setClientSetting(SETTINGS.INSTANT_PURCHASE_ENABLED, false)}
/>
<FormField
type="radio"
name="instant_purchases"
checked={instantPurchaseEnabled}
label={__('Only confirm purchases or tips over a certain amount')}
helper={__(HELP_ONLY_CONFIRM_OVER_AMOUNT)}
onChange={() => setClientSetting(SETTINGS.INSTANT_PURCHASE_ENABLED, true)}
/>
{instantPurchaseEnabled && (
<FormFieldPrice
name="confirmation_price"
min={0.1}
onChange={(newValue) => setClientSetting(SETTINGS.INSTANT_PURCHASE_MAX, newValue)}
price={instantPurchaseMax}
/>
)}
</SettingsRow>
</> </>
} }
/> />
@ -159,3 +194,5 @@ const HELP_SHOW_MATURE =
'Mature content may include nudity, intense sexuality, profanity, or other adult content. By displaying mature content, you are affirming you are of legal age to view mature content in your country or jurisdiction. '; 'Mature content may include nudity, intense sexuality, profanity, or other adult content. By displaying mature content, you are affirming you are of legal age to view mature content in your country or jurisdiction. ';
const HELP_MAX_PURCHASE_PRICE = const HELP_MAX_PURCHASE_PRICE =
'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.';
const HELP_ONLY_CONFIRM_OVER_AMOUNT = ''; // feel redundant. Disable for now.
// const HELP_ONLY_CONFIRM_OVER_AMOUNT = "When this option is chosen, LBRY won't ask you to confirm purchases or tips below your chosen amount.";

View file

@ -22,8 +22,6 @@ const select = (state) => ({
daemonSettings: selectDaemonSettings(state), daemonSettings: selectDaemonSettings(state),
allowAnalytics: selectAllowAnalytics(state), allowAnalytics: selectAllowAnalytics(state),
isAuthenticated: selectUserVerifiedEmail(state), isAuthenticated: selectUserVerifiedEmail(state),
instantPurchaseEnabled: makeSelectClientSetting(SETTINGS.INSTANT_PURCHASE_ENABLED)(state),
instantPurchaseMax: makeSelectClientSetting(SETTINGS.INSTANT_PURCHASE_MAX)(state),
walletEncrypted: selectWalletIsEncrypted(state), walletEncrypted: selectWalletIsEncrypted(state),
hideBalance: makeSelectClientSetting(SETTINGS.HIDE_BALANCE)(state), hideBalance: makeSelectClientSetting(SETTINGS.HIDE_BALANCE)(state),
ffmpegStatus: selectFfmpegStatus(state), ffmpegStatus: selectFfmpegStatus(state),

View file

@ -1,7 +1,7 @@
// @flow // @flow
import * as React from 'react'; import * as React from 'react';
import { FormField, FormFieldPrice } from 'component/common/form'; import { FormField } from 'component/common/form';
import Button from 'component/button'; import Button from 'component/button';
import I18nMessage from 'component/i18nMessage'; import I18nMessage from 'component/i18nMessage';
import Page from 'component/page'; import Page from 'component/page';
@ -36,8 +36,6 @@ type Props = {
setClientSetting: (string, SetDaemonSettingArg) => void, setClientSetting: (string, SetDaemonSettingArg) => void,
daemonSettings: DaemonSettings, daemonSettings: DaemonSettings,
isAuthenticated: boolean, isAuthenticated: boolean,
instantPurchaseEnabled: boolean,
instantPurchaseMax: Price,
encryptWallet: () => void, encryptWallet: () => void,
decryptWallet: () => void, decryptWallet: () => void,
updateWalletStatus: () => void, updateWalletStatus: () => void,
@ -67,7 +65,6 @@ class SettingsAdvancedPage extends React.PureComponent<Props, State> {
}; };
(this: any).onMaxConnectionsChange = this.onMaxConnectionsChange.bind(this); (this: any).onMaxConnectionsChange = this.onMaxConnectionsChange.bind(this);
(this: any).onInstantPurchaseMaxChange = this.onInstantPurchaseMaxChange.bind(this);
(this: any).onThemeChange = this.onThemeChange.bind(this); (this: any).onThemeChange = this.onThemeChange.bind(this);
(this: any).onAutomaticDarkModeChange = this.onAutomaticDarkModeChange.bind(this); (this: any).onAutomaticDarkModeChange = this.onAutomaticDarkModeChange.bind(this);
(this: any).onConfirmForgetPassword = this.onConfirmForgetPassword.bind(this); (this: any).onConfirmForgetPassword = this.onConfirmForgetPassword.bind(this);
@ -127,14 +124,6 @@ class SettingsAdvancedPage extends React.PureComponent<Props, State> {
this.props.setClientSetting(SETTINGS.AUTOMATIC_DARK_MODE_ENABLED, value); this.props.setClientSetting(SETTINGS.AUTOMATIC_DARK_MODE_ENABLED, value);
} }
onInstantPurchaseEnabledChange(enabled: boolean) {
this.props.setClientSetting(SETTINGS.INSTANT_PURCHASE_ENABLED, enabled);
}
onInstantPurchaseMaxChange(newValue: Price) {
this.props.setClientSetting(SETTINGS.INSTANT_PURCHASE_MAX, newValue);
}
onChangeEncryptWallet() { onChangeEncryptWallet() {
const { decryptWallet, walletEncrypted, encryptWallet } = this.props; const { decryptWallet, walletEncrypted, encryptWallet } = this.props;
if (walletEncrypted) { if (walletEncrypted) {
@ -169,8 +158,6 @@ class SettingsAdvancedPage extends React.PureComponent<Props, State> {
const { const {
daemonSettings, daemonSettings,
ffmpegStatus, ffmpegStatus,
instantPurchaseEnabled,
instantPurchaseMax,
isAuthenticated, isAuthenticated,
walletEncrypted, walletEncrypted,
setClientSetting, setClientSetting,
@ -201,47 +188,6 @@ class SettingsAdvancedPage extends React.PureComponent<Props, State> {
</section> </section>
) : ( ) : (
<div> <div>
<Card
title={__('Purchase and tip confirmations')}
actions={
<React.Fragment>
<FormField
type="radio"
name="confirm_all_purchases"
checked={!instantPurchaseEnabled}
label={__('Always confirm before purchasing content or tipping')}
onChange={() => {
this.onInstantPurchaseEnabledChange(false);
}}
/>
<FormField
type="radio"
name="instant_purchases"
checked={instantPurchaseEnabled}
label={__('Only confirm purchases or tips over a certain amount')}
onChange={() => {
this.onInstantPurchaseEnabledChange(true);
}}
/>
{instantPurchaseEnabled && (
<FormFieldPrice
name="confirmation_price"
min={0.1}
onChange={this.onInstantPurchaseMaxChange}
price={instantPurchaseMax}
/>
)}
<p className="help">
{__(
"When this option is chosen, LBRY won't ask you to confirm purchases or tips below your chosen amount."
)}
</p>
</React.Fragment>
}
/>
{(isAuthenticated || !IS_WEB) && ( {(isAuthenticated || !IS_WEB) && (
<Card <Card
title={__('Wallet security')} title={__('Wallet security')}