[Content] grab original "Content Settings"
This commit is contained in:
parent
c539e4e10d
commit
859ccf5ea9
4 changed files with 143 additions and 105 deletions
24
ui/component/settingContent/index.js
Normal file
24
ui/component/settingContent/index.js
Normal file
|
@ -0,0 +1,24 @@
|
|||
import { connect } from 'react-redux';
|
||||
import { SETTINGS } from 'lbry-redux';
|
||||
import { doOpenModal } from 'redux/actions/app';
|
||||
import { doSetPlayingUri } from 'redux/actions/content';
|
||||
import { doSetClientSetting } from 'redux/actions/settings';
|
||||
import { selectShowMatureContent, makeSelectClientSetting } from 'redux/selectors/settings';
|
||||
import { selectUserVerifiedEmail } from 'redux/selectors/user';
|
||||
import SettingContent from './view';
|
||||
|
||||
const select = (state) => ({
|
||||
isAuthenticated: selectUserVerifiedEmail(state),
|
||||
floatingPlayer: makeSelectClientSetting(SETTINGS.FLOATING_PLAYER)(state),
|
||||
autoplay: makeSelectClientSetting(SETTINGS.AUTOPLAY)(state),
|
||||
hideReposts: makeSelectClientSetting(SETTINGS.HIDE_REPOSTS)(state),
|
||||
showNsfw: selectShowMatureContent(state),
|
||||
});
|
||||
|
||||
const perform = (dispatch) => ({
|
||||
setClientSetting: (key, value) => dispatch(doSetClientSetting(key, value)),
|
||||
clearPlayingUri: () => dispatch(doSetPlayingUri({ uri: null })),
|
||||
openModal: (id, params) => dispatch(doOpenModal(id, params)),
|
||||
});
|
||||
|
||||
export default connect(select, perform)(SettingContent);
|
115
ui/component/settingContent/view.jsx
Normal file
115
ui/component/settingContent/view.jsx
Normal file
|
@ -0,0 +1,115 @@
|
|||
// @flow
|
||||
import React from 'react';
|
||||
import { SETTINGS } from 'lbry-redux';
|
||||
import { Lbryio } from 'lbryinc';
|
||||
import { SIMPLE_SITE } from 'config';
|
||||
import * as MODALS from 'constants/modal_types';
|
||||
import Card from 'component/common/card';
|
||||
import { FormField } from 'component/common/form';
|
||||
import MaxPurchasePrice from 'component/maxPurchasePrice';
|
||||
import SettingsRow from 'component/settingsRow';
|
||||
|
||||
const HELP_FLOATING_PLAYER = 'Keep content playing in the corner when navigating to a different page.';
|
||||
const HELP_AUTOPLAY =
|
||||
'Autoplay video and audio files when navigating to a file, as well as the next related item when a file finishes playing.';
|
||||
const HELP_HIDE_REPOSTS = 'You will not see reposts by people you follow or receive email notifying about them.';
|
||||
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. ';
|
||||
|
||||
type Props = {
|
||||
isAuthenticated: boolean,
|
||||
floatingPlayer: boolean,
|
||||
autoplay: boolean,
|
||||
hideReposts: ?boolean,
|
||||
showNsfw: boolean,
|
||||
setClientSetting: (string, boolean | string | number) => void,
|
||||
clearPlayingUri: () => void,
|
||||
openModal: (string) => void,
|
||||
};
|
||||
|
||||
export default function SettingContent(props: Props) {
|
||||
const {
|
||||
isAuthenticated,
|
||||
floatingPlayer,
|
||||
autoplay,
|
||||
hideReposts,
|
||||
showNsfw,
|
||||
setClientSetting,
|
||||
clearPlayingUri,
|
||||
openModal,
|
||||
} = props;
|
||||
|
||||
return (
|
||||
<Card
|
||||
title={__('Content settings')}
|
||||
subtitle=""
|
||||
isBodyList
|
||||
body={
|
||||
<>
|
||||
<SettingsRow title={__('Floating video player')} subtitle={__(HELP_FLOATING_PLAYER)}>
|
||||
<FormField
|
||||
type="checkbox"
|
||||
name="floating_player"
|
||||
onChange={() => {
|
||||
setClientSetting(SETTINGS.FLOATING_PLAYER, !floatingPlayer);
|
||||
clearPlayingUri();
|
||||
}}
|
||||
checked={floatingPlayer}
|
||||
/>
|
||||
</SettingsRow>
|
||||
|
||||
<SettingsRow title={__('Autoplay media files')} subtitle={__(HELP_AUTOPLAY)}>
|
||||
<FormField
|
||||
type="checkbox"
|
||||
name="autoplay"
|
||||
onChange={() => setClientSetting(SETTINGS.AUTOPLAY, !autoplay)}
|
||||
checked={autoplay}
|
||||
/>
|
||||
</SettingsRow>
|
||||
|
||||
{!SIMPLE_SITE && (
|
||||
<>
|
||||
<SettingsRow title={__('Hide reposts')} subtitle={__(HELP_HIDE_REPOSTS)}>
|
||||
<FormField
|
||||
type="checkbox"
|
||||
name="hide_reposts"
|
||||
onChange={(e) => {
|
||||
if (isAuthenticated) {
|
||||
let param = e.target.checked ? { add: 'noreposts' } : { remove: 'noreposts' };
|
||||
Lbryio.call('user_tag', 'edit', param);
|
||||
}
|
||||
setClientSetting(SETTINGS.HIDE_REPOSTS, !hideReposts);
|
||||
}}
|
||||
/>
|
||||
</SettingsRow>
|
||||
|
||||
{/*
|
||||
<SettingsRow title={__('Show anonymous content')} subtitle={__('Anonymous content is published without a channel.')} >
|
||||
<FormField
|
||||
type="checkbox"
|
||||
name="show_anonymous"
|
||||
onChange={() => setClientSetting(SETTINGS.SHOW_ANONYMOUS, !showAnonymous)}
|
||||
checked={showAnonymous}
|
||||
/>
|
||||
</SettingsRow>
|
||||
*/}
|
||||
|
||||
<SettingsRow title={__('Show mature content')} subtitle={__(HELP_SHOW_MATURE)}>
|
||||
<FormField
|
||||
type="checkbox"
|
||||
name="show_nsfw"
|
||||
checked={showNsfw}
|
||||
onChange={() =>
|
||||
!IS_WEB || showNsfw
|
||||
? setClientSetting(SETTINGS.SHOW_MATURE, !showNsfw)
|
||||
: openModal(MODALS.CONFIRM_AGE)
|
||||
}
|
||||
/>
|
||||
</SettingsRow>
|
||||
</>
|
||||
)}
|
||||
</>
|
||||
}
|
||||
/>
|
||||
);
|
||||
}
|
|
@ -1,15 +1,13 @@
|
|||
import { connect } from 'react-redux';
|
||||
import { doToggle3PAnalytics, doOpenModal } from 'redux/actions/app';
|
||||
import { doToggle3PAnalytics } from 'redux/actions/app';
|
||||
import { selectAllowAnalytics } from 'redux/selectors/app';
|
||||
import {
|
||||
doSetDaemonSetting,
|
||||
doClearDaemonSetting,
|
||||
doSetClientSetting,
|
||||
doEnterSettingsPage,
|
||||
doExitSettingsPage,
|
||||
} from 'redux/actions/settings';
|
||||
import { doSetPlayingUri } from 'redux/actions/content';
|
||||
import { makeSelectClientSetting, selectDaemonSettings, selectShowMatureContent } from 'redux/selectors/settings';
|
||||
import { makeSelectClientSetting, selectDaemonSettings } from 'redux/selectors/settings';
|
||||
import { selectMyChannelUrls, SETTINGS } from 'lbry-redux';
|
||||
import SettingsPage from './view';
|
||||
import { selectUserVerifiedEmail, selectUser } from 'redux/selectors/user';
|
||||
|
@ -18,12 +16,8 @@ const select = (state) => ({
|
|||
daemonSettings: selectDaemonSettings(state),
|
||||
allowAnalytics: selectAllowAnalytics(state),
|
||||
isAuthenticated: selectUserVerifiedEmail(state),
|
||||
showNsfw: selectShowMatureContent(state),
|
||||
autoplay: makeSelectClientSetting(SETTINGS.AUTOPLAY)(state),
|
||||
autoDownload: makeSelectClientSetting(SETTINGS.AUTO_DOWNLOAD)(state),
|
||||
hideBalance: makeSelectClientSetting(SETTINGS.HIDE_BALANCE)(state),
|
||||
floatingPlayer: makeSelectClientSetting(SETTINGS.FLOATING_PLAYER)(state),
|
||||
hideReposts: makeSelectClientSetting(SETTINGS.HIDE_REPOSTS)(state),
|
||||
myChannelUrls: selectMyChannelUrls(state),
|
||||
user: selectUser(state),
|
||||
});
|
||||
|
@ -32,9 +26,6 @@ const perform = (dispatch) => ({
|
|||
setDaemonSetting: (key, value) => dispatch(doSetDaemonSetting(key, value)),
|
||||
clearDaemonSetting: (key) => dispatch(doClearDaemonSetting(key)),
|
||||
toggle3PAnalytics: (allow) => dispatch(doToggle3PAnalytics(allow)),
|
||||
setClientSetting: (key, value) => dispatch(doSetClientSetting(key, value)),
|
||||
clearPlayingUri: () => dispatch(doSetPlayingUri({ uri: null })),
|
||||
openModal: (id, params) => dispatch(doOpenModal(id, params)),
|
||||
enterSettings: () => dispatch(doEnterSettingsPage()),
|
||||
exitSettings: () => dispatch(doExitSettingsPage()),
|
||||
});
|
||||
|
|
|
@ -1,20 +1,17 @@
|
|||
// @flow
|
||||
import * as PAGES from 'constants/pages';
|
||||
import * as MODALS from 'constants/modal_types';
|
||||
import * as ICONS from 'constants/icons';
|
||||
import * as React from 'react';
|
||||
import { SETTINGS } from 'lbry-redux';
|
||||
import { FormField } from 'component/common/form';
|
||||
import Button from 'component/button';
|
||||
import Page from 'component/page';
|
||||
import SettingAccount from 'component/settingAccount';
|
||||
import SettingAppearance from 'component/settingAppearance';
|
||||
import SettingContent from 'component/settingContent';
|
||||
import SettingSystem from 'component/settingSystem';
|
||||
import FileSelector from 'component/common/file-selector';
|
||||
import Card from 'component/common/card';
|
||||
import classnames from 'classnames';
|
||||
import { SIMPLE_SITE } from 'config';
|
||||
import { Lbryio } from 'lbryinc';
|
||||
import Yrbl from 'component/yrbl';
|
||||
import { getStripeEnvironment } from 'util/stripe';
|
||||
|
||||
|
@ -33,18 +30,12 @@ type DaemonSettings = {
|
|||
type Props = {
|
||||
setDaemonSetting: (string, ?SetDaemonSettingArg) => void,
|
||||
clearDaemonSetting: (string) => void,
|
||||
setClientSetting: (string, SetDaemonSettingArg) => void,
|
||||
toggle3PAnalytics: (boolean) => void,
|
||||
daemonSettings: DaemonSettings,
|
||||
allowAnalytics: boolean,
|
||||
showNsfw: boolean,
|
||||
isAuthenticated: boolean,
|
||||
instantPurchaseEnabled: boolean,
|
||||
instantPurchaseMax: Price,
|
||||
autoplay: boolean,
|
||||
floatingPlayer: boolean,
|
||||
hideReposts: ?boolean,
|
||||
clearPlayingUri: () => void,
|
||||
openModal: (string) => void,
|
||||
enterSettings: () => void,
|
||||
exitSettings: () => void,
|
||||
|
@ -75,17 +66,10 @@ class SettingsPage extends React.PureComponent<Props> {
|
|||
const {
|
||||
daemonSettings,
|
||||
allowAnalytics,
|
||||
showNsfw,
|
||||
isAuthenticated,
|
||||
autoplay,
|
||||
// autoDownload,
|
||||
setDaemonSetting,
|
||||
setClientSetting,
|
||||
toggle3PAnalytics,
|
||||
floatingPlayer,
|
||||
hideReposts,
|
||||
clearPlayingUri,
|
||||
openModal,
|
||||
myChannelUrls,
|
||||
user,
|
||||
} = this.props;
|
||||
|
@ -96,6 +80,7 @@ class SettingsPage extends React.PureComponent<Props> {
|
|||
<Page noFooter noSideNavigation backout={{ title: __('Settings'), backLabel: __('Done') }} className="card-stack">
|
||||
<SettingAppearance />
|
||||
<SettingAccount />
|
||||
<SettingContent />
|
||||
<SettingSystem />
|
||||
</Page>
|
||||
) : (
|
||||
|
@ -147,83 +132,6 @@ class SettingsPage extends React.PureComponent<Props> {
|
|||
/>
|
||||
{/* @endif */}
|
||||
|
||||
<Card
|
||||
title={__('Content settings')}
|
||||
actions={
|
||||
<React.Fragment>
|
||||
<FormField
|
||||
type="checkbox"
|
||||
name="floating_player"
|
||||
onChange={() => {
|
||||
setClientSetting(SETTINGS.FLOATING_PLAYER, !floatingPlayer);
|
||||
clearPlayingUri();
|
||||
}}
|
||||
checked={floatingPlayer}
|
||||
label={__('Floating video player')}
|
||||
helper={__('Keep content playing in the corner when navigating to a different page.')}
|
||||
/>
|
||||
|
||||
<FormField
|
||||
type="checkbox"
|
||||
name="autoplay"
|
||||
onChange={() => setClientSetting(SETTINGS.AUTOPLAY, !autoplay)}
|
||||
checked={autoplay}
|
||||
label={__('Autoplay media files')}
|
||||
helper={__(
|
||||
'Autoplay video and audio files when navigating to a file, as well as the next related item when a file finishes playing.'
|
||||
)}
|
||||
/>
|
||||
{!SIMPLE_SITE && (
|
||||
<>
|
||||
<FormField
|
||||
type="checkbox"
|
||||
name="hide_reposts"
|
||||
onChange={(e) => {
|
||||
if (isAuthenticated) {
|
||||
let param = e.target.checked ? { add: 'noreposts' } : { remove: 'noreposts' };
|
||||
Lbryio.call('user_tag', 'edit', param);
|
||||
}
|
||||
|
||||
setClientSetting(SETTINGS.HIDE_REPOSTS, !hideReposts);
|
||||
}}
|
||||
checked={hideReposts}
|
||||
label={__('Hide reposts')}
|
||||
helper={__(
|
||||
'You will not see reposts by people you follow or receive email notifying about them.'
|
||||
)}
|
||||
/>
|
||||
|
||||
{/*
|
||||
<FormField
|
||||
type="checkbox"
|
||||
name="show_anonymous"
|
||||
onChange={() => setClientSetting(SETTINGS.SHOW_ANONYMOUS, !showAnonymous)}
|
||||
checked={showAnonymous}
|
||||
label={__('Show anonymous content')}
|
||||
helper={__('Anonymous content is published without a channel.')}
|
||||
/>
|
||||
*/}
|
||||
|
||||
<FormField
|
||||
type="checkbox"
|
||||
name="show_nsfw"
|
||||
onChange={() =>
|
||||
!IS_WEB || showNsfw
|
||||
? setClientSetting(SETTINGS.SHOW_MATURE, !showNsfw)
|
||||
: openModal(MODALS.CONFIRM_AGE)
|
||||
}
|
||||
checked={showNsfw}
|
||||
label={__('Show mature content')}
|
||||
helper={__(
|
||||
'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. '
|
||||
)}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
</React.Fragment>
|
||||
}
|
||||
/>
|
||||
|
||||
{/* @if TARGET='app' */}
|
||||
<Card
|
||||
title={__('Share usage and diagnostic data')}
|
||||
|
|
Loading…
Reference in a new issue