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 ,
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 ,
} ;
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 ,
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 ,
} = props ;
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-29 22:44:59 +01:00
checked = { hideReposts }
2021-10-19 01:37:58 +02:00
/ >
< / SettingsRow >
< 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.' ,
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
} ;