2021-08-06 04:41:37 +02:00
// @flow
2021-08-06 09:56:48 +02:00
import * as ICONS from 'constants/icons' ;
import * as PAGES from 'constants/pages' ;
2021-08-06 04:41:37 +02:00
import React from 'react' ;
2021-10-08 05:47:39 +02:00
import * as SETTINGS from 'constants/settings' ;
2021-08-06 04:41:37 +02:00
import { Lbryio } from 'lbryinc' ;
2021-08-08 10:13:35 +02:00
import { SETTINGS _GRP } from 'constants/settings' ;
2021-08-06 09:56:48 +02:00
import Button from 'component/button' ;
2021-08-06 04:41:37 +02:00
import Card from 'component/common/card' ;
2021-08-07 14:40:17 +02:00
import { FormField , FormFieldPrice } from 'component/common/form' ;
2021-08-06 04:41:37 +02:00
import MaxPurchasePrice from 'component/maxPurchasePrice' ;
import SettingsRow from 'component/settingsRow' ;
2021-08-07 14:40:17 +02:00
type Price = {
currency : string ,
amount : number ,
} ;
2021-08-06 04:41:37 +02:00
type Props = {
2021-08-07 14:50:24 +02:00
// --- select ---
2021-08-06 04:41:37 +02:00
isAuthenticated : boolean ,
floatingPlayer : boolean ,
2021-09-02 22:05:32 +02:00
autoplayMedia : boolean ,
autoplayNext : boolean ,
2021-08-06 04:41:37 +02:00
hideReposts : ? boolean ,
showNsfw : boolean ,
2022-04-22 05:00:57 +02:00
persistWatchTime : boolean ,
2021-08-06 09:56:48 +02:00
myChannelUrls : ? Array < string > ,
2021-08-07 14:40:17 +02:00
instantPurchaseEnabled : boolean ,
instantPurchaseMax : Price ,
2021-08-07 14:50:24 +02:00
enablePublishPreview : boolean ,
// --- perform ---
2021-08-06 04:41:37 +02:00
setClientSetting : ( string , boolean | string | number ) => void ,
clearPlayingUri : ( ) => void ,
2022-04-22 05:00:57 +02:00
// clearContentCache: () => void,
2021-08-06 04:41:37 +02:00
} ;
export default function SettingContent ( props : Props ) {
const {
isAuthenticated ,
floatingPlayer ,
2021-09-02 22:05:32 +02:00
autoplayMedia ,
autoplayNext ,
2021-08-06 04:41:37 +02:00
hideReposts ,
2022-04-22 05:00:57 +02:00
persistWatchTime ,
2021-08-06 04:41:37 +02:00
showNsfw ,
2021-08-06 09:56:48 +02:00
myChannelUrls ,
2021-08-07 14:40:17 +02:00
instantPurchaseEnabled ,
instantPurchaseMax ,
2021-08-07 14:50:24 +02:00
enablePublishPreview ,
2021-08-06 04:41:37 +02:00
setClientSetting ,
clearPlayingUri ,
2022-04-22 05:00:57 +02:00
// clearContentCache,
2021-08-06 04:41:37 +02:00
} = props ;
2022-04-22 05:00:57 +02:00
// feature disabled until styling is ironed out
// const [contentCacheCleared, setContentCacheCleared] = React.useState(false);
// const [clearingContentCache, setClearingContentCache] = React.useState(false);
// const onClearContentCache = React.useCallback(() => {
// setClearingContentCache(true);
// clearContentCache();
// // Just a small timer to give the user a visual effect
// // that the content is being cleared.
// setTimeout(() => {
// setClearingContentCache(false);
// setContentCacheCleared(true);
// }, 2000);
// }, [setClearingContentCache, clearContentCache, setContentCacheCleared]);
2021-08-06 04:41:37 +02:00
return (
2021-08-09 04:22:16 +02:00
< >
< div className = "card__title-section" >
< h2 className = "card__title" > { _ _ ( 'Content settings' ) } < / h2 >
< / div >
< Card
id = { SETTINGS _GRP . CONTENT }
isBodyList
body = {
< >
2021-08-19 09:10:04 +02:00
< SettingsRow title = { _ _ ( 'Floating video player' ) } subtitle = { _ _ ( HELP . FLOATING _PLAYER ) } >
2021-08-09 04:22:16 +02:00
< FormField
type = "checkbox"
name = "floating_player"
onChange = { ( ) => {
setClientSetting ( SETTINGS . FLOATING _PLAYER , ! floatingPlayer ) ;
clearPlayingUri ( ) ;
} }
checked = { floatingPlayer }
/ >
< / SettingsRow >
2021-08-06 04:41:37 +02:00
2021-09-02 22:05:32 +02:00
< SettingsRow title = { _ _ ( 'Autoplay media files' ) } subtitle = { _ _ ( HELP . AUTOPLAY _MEDIA ) } >
2021-08-09 04:22:16 +02:00
< FormField
type = "checkbox"
2021-09-02 22:05:32 +02:00
name = "autoplay media"
onChange = { ( ) => setClientSetting ( SETTINGS . AUTOPLAY _MEDIA , ! autoplayMedia ) }
checked = { autoplayMedia }
/ >
< / SettingsRow >
< SettingsRow title = { _ _ ( 'Autoplay next recommended content' ) } subtitle = { _ _ ( HELP . AUTOPLAY _NEXT ) } >
< FormField
type = "checkbox"
name = "autoplay next"
onChange = { ( ) => setClientSetting ( SETTINGS . AUTOPLAY _NEXT , ! autoplayNext ) }
checked = { autoplayNext }
2021-08-09 04:22:16 +02:00
/ >
< / SettingsRow >
2021-10-19 01:37:58 +02:00
< 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 ) ;
} }
2022-01-30 00:25:40 +01:00
checked = { hideReposts }
2021-10-19 01:37:58 +02:00
/ >
< / SettingsRow >
2022-04-22 05:00:57 +02:00
< SettingsRow title = { _ _ ( 'Show Video View Progress' ) } subtitle = { _ _ ( HELP . PERSIST _WATCH _TIME ) } >
{ /* <div className="settings__persistWatchTimeCheckbox"> */ }
< FormField
type = "checkbox"
name = "persist_watch_time"
onChange = { ( ) => setClientSetting ( SETTINGS . PERSIST _WATCH _TIME , ! persistWatchTime ) }
checked = { persistWatchTime }
/ >
{ / * < / d i v >
Disabled until styling is better
< div className = "settings__persistWatchTimeClearCache" >
< Button
button = "primary"
icon = { ICONS . ALERT }
label = {
contentCacheCleared
? _ _ ( 'Views cleared' )
: clearingContentCache
? _ _ ( 'Clearing...' )
: _ _ ( 'Clear Views' )
}
onClick = { onClearContentCache }
disabled = { clearingContentCache || contentCacheCleared }
/ >
< / div > * / }
< / SettingsRow >
2021-10-19 01:37:58 +02:00
< SettingsRow title = { _ _ ( 'Show mature content' ) } subtitle = { _ _ ( HELP . SHOW _MATURE ) } >
< FormField
type = "checkbox"
name = "show_nsfw"
checked = { showNsfw }
2022-01-07 20:02:33 +01:00
onChange = { ( ) => setClientSetting ( SETTINGS . SHOW _MATURE , ! showNsfw ) }
/ >
< / SettingsRow >
< SettingsRow title = { _ _ ( 'Notifications' ) } >
< Button
button = "inverse"
label = { _ _ ( 'Manage' ) }
icon = { ICONS . ARROW _RIGHT }
navigate = { ` / $ / ${ PAGES . SETTINGS _NOTIFICATIONS } ` }
2021-10-19 01:37:58 +02:00
/ >
< / SettingsRow >
2021-08-06 09:56:48 +02:00
2022-01-07 20:02:33 +01:00
< SettingsRow title = { _ _ ( 'Blocked and muted channels' ) } >
< Button
button = "inverse"
label = { _ _ ( 'Manage' ) }
icon = { ICONS . ARROW _RIGHT }
navigate = { ` / $ / ${ PAGES . SETTINGS _BLOCKED _MUTED } ` }
/ >
< / SettingsRow >
2021-08-06 09:56:48 +02:00
2022-01-07 20:02:33 +01:00
{ myChannelUrls && myChannelUrls . length > 0 && (
< SettingsRow title = { _ _ ( 'Creator settings' ) } >
< Button
button = "inverse"
label = { _ _ ( 'Manage' ) }
icon = { ICONS . ARROW _RIGHT }
navigate = { ` / $ / ${ PAGES . SETTINGS _CREATOR } ` }
/ >
< / SettingsRow >
2021-08-09 04:22:16 +02:00
) }
2021-08-19 09:18:36 +02:00
< SettingsRow title = { _ _ ( 'Publish confirmation' ) } subtitle = { _ _ ( HELP . PUBLISH _PREVIEW ) } >
2021-08-09 04:22:16 +02:00
< FormField
type = "checkbox"
2022-01-04 15:36:44 +01:00
name = "publish_confirmation"
2021-08-09 04:22:16 +02:00
label = { _ _ ( '' ) }
2021-08-19 09:18:36 +02:00
checked = { enablePublishPreview }
2021-08-09 04:22:16 +02:00
onChange = { ( ) => setClientSetting ( SETTINGS . ENABLE _PUBLISH _PREVIEW , ! enablePublishPreview ) }
/ >
< / SettingsRow >
2021-08-22 09:58:56 +02:00
< SettingsRow title = { _ _ ( 'Max purchase price' ) } subtitle = { _ _ ( HELP . MAX _PURCHASE _PRICE ) } multirow >
2021-08-09 04:22:16 +02:00
< MaxPurchasePrice / >
< / SettingsRow >
2021-08-22 09:58:56 +02:00
< SettingsRow title = { _ _ ( 'Purchase and tip confirmations' ) } multirow >
2021-08-09 04:22:16 +02:00
< FormField
type = "radio"
name = "confirm_all_purchases"
checked = { ! instantPurchaseEnabled }
label = { _ _ ( 'Always confirm before purchasing content or tipping' ) }
onChange = { ( ) => setClientSetting ( SETTINGS . INSTANT _PURCHASE _ENABLED , false ) }
2021-08-07 14:40:17 +02:00
/ >
2021-08-09 04:22:16 +02:00
< FormField
type = "radio"
name = "instant_purchases"
checked = { instantPurchaseEnabled }
label = { _ _ ( 'Only confirm purchases or tips over a certain amount' ) }
2021-08-19 09:10:04 +02:00
helper = { _ _ ( HELP . ONLY _CONFIRM _OVER _AMOUNT ) }
2021-08-09 04:22:16 +02:00
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 >
< / >
}
/ >
< / >
2021-08-06 04:41:37 +02:00
) ;
}
2021-08-06 09:56:48 +02:00
2021-08-19 09:10:04 +02:00
// prettier-ignore
const HELP = {
FLOATING _PLAYER : 'Keep content playing in the corner when navigating to a different page.' ,
2021-09-02 22:05:32 +02:00
AUTOPLAY _MEDIA : 'Autoplay video and audio files when navigating to a file.' ,
2021-09-11 04:17:54 +02:00
AUTOPLAY _NEXT : 'Autoplay the next related item when a file (video or audio) finishes playing.' ,
2021-08-19 09:10:04 +02:00
HIDE _REPOSTS : 'You will not see reposts by people you follow or receive email notifying about them.' ,
2022-04-22 05:00:57 +02:00
PERSIST _WATCH _TIME : 'Display view progress on thumbnail. This setting will not hide any blockchain activity or downloads.' ,
2021-08-19 09:10:04 +02:00
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. ' ,
MAX _PURCHASE _PRICE : 'This will prevent you from purchasing any content over a certain cost, as a safety measure.' ,
ONLY _CONFIRM _OVER _AMOUNT : '' , // [feel redundant. Disable for now] "When this option is chosen, LBRY won't ask you to confirm purchases or tips below your chosen amount.",
2021-08-19 09:18:36 +02:00
PUBLISH _PREVIEW : 'Show preview and confirmation dialog before publishing content.' ,
2021-08-19 09:10:04 +02:00
} ;