watch time ux

This commit is contained in:
zeppi 2022-04-21 21:26:29 -04:00
parent c685bb4922
commit b4669d841e
6 changed files with 50 additions and 43 deletions

View file

@ -2311,9 +2311,9 @@
"Elements": "Elements", "Elements": "Elements",
"Icons": "Icons", "Icons": "Icons",
"Go to": "Go to", "Go to": "Go to",
"Persist watch time": "Persist watch time",
"Clearing...": "Clearing...", "Clearing...": "Clearing...",
"Clear Views": "Clear Views", "Clear Views": "Clear Views",
"Persist the watch time of the videos you have watched. This will not erase or hide any blockchain activity or downloads.": "Persist the watch time of the videos you have watched. This will not erase or hide any blockchain activity or downloads.", "Show Video View Progress": "Show Video View Progress",
"Display view progress on thumbnail. This setting will not hide any blockchain activity or downloads.": "Display view progress on thumbnail. This setting will not hide any blockchain activity or downloads.",
"--end--": "--end--" "--end--": "--end--"
} }

View file

@ -3,11 +3,14 @@ import { doResolveUri } from 'redux/actions/claims';
import { makeSelectClaimForUri } from 'redux/selectors/claims'; import { makeSelectClaimForUri } from 'redux/selectors/claims';
import { makeSelectContentWatchedPercentageForUri } from 'redux/selectors/content'; import { makeSelectContentWatchedPercentageForUri } from 'redux/selectors/content';
import CardMedia from './view'; import CardMedia from './view';
import { makeSelectClientSetting } from 'redux/selectors/settings';
import * as SETTINGS from 'constants/settings';
const select = (state, props) => { const select = (state, props) => {
return { return {
watchedPercentage: makeSelectContentWatchedPercentageForUri(props.uri)(state), watchedPercentage: makeSelectContentWatchedPercentageForUri(props.uri)(state),
claim: makeSelectClaimForUri(props.uri)(state), claim: makeSelectClaimForUri(props.uri)(state),
showPercentage: makeSelectClientSetting(SETTINGS.PERSIST_WATCH_TIME)(state),
}; };
}; };

View file

@ -17,6 +17,7 @@ type Props = {
doResolveUri: (string) => void, doResolveUri: (string) => void,
className?: string, className?: string,
watchedPercentage: number, watchedPercentage: number,
showPercentage: boolean,
}; };
function FileThumbnail(props: Props) { function FileThumbnail(props: Props) {
@ -29,6 +30,7 @@ function FileThumbnail(props: Props) {
allowGifs = false, allowGifs = false,
className, className,
watchedPercentage, watchedPercentage,
showPercentage,
} = props; } = props;
const passedThumbnail = rawThumbnail && rawThumbnail.trim().replace(/^http:\/\//i, 'https://'); const passedThumbnail = rawThumbnail && rawThumbnail.trim().replace(/^http:\/\//i, 'https://');
@ -39,7 +41,7 @@ function FileThumbnail(props: Props) {
const hasResolvedClaim = claim !== undefined; const hasResolvedClaim = claim !== undefined;
const isGif = thumbnail && thumbnail.endsWith('gif'); const isGif = thumbnail && thumbnail.endsWith('gif');
const viewedBar = watchedPercentage && ( const viewedBar = showPercentage && watchedPercentage && (
<div className="file-thumbnail__viewed-bar"> <div className="file-thumbnail__viewed-bar">
<div className="file-thumbnail__viewed-bar-progress" style={{ width: `${watchedPercentage}%` }} /> <div className="file-thumbnail__viewed-bar-progress" style={{ width: `${watchedPercentage}%` }} />
</div> </div>

View file

@ -32,7 +32,7 @@ type Props = {
// --- perform --- // --- perform ---
setClientSetting: (string, boolean | string | number) => void, setClientSetting: (string, boolean | string | number) => void,
clearPlayingUri: () => void, clearPlayingUri: () => void,
clearContentCache: () => void, // clearContentCache: () => void,
}; };
export default function SettingContent(props: Props) { export default function SettingContent(props: Props) {
@ -50,20 +50,21 @@ export default function SettingContent(props: Props) {
enablePublishPreview, enablePublishPreview,
setClientSetting, setClientSetting,
clearPlayingUri, clearPlayingUri,
clearContentCache, // clearContentCache,
} = props; } = props;
const [contentCacheCleared, setContentCacheCleared] = React.useState(false); // feature disabled until styling is ironed out
const [clearingContentCache, setClearingContentCache] = React.useState(false); // const [contentCacheCleared, setContentCacheCleared] = React.useState(false);
const onClearContentCache = React.useCallback(() => { // const [clearingContentCache, setClearingContentCache] = React.useState(false);
setClearingContentCache(true); // const onClearContentCache = React.useCallback(() => {
clearContentCache(); // setClearingContentCache(true);
// Just a small timer to give the user a visual effect // clearContentCache();
// that the content is being cleared. // // Just a small timer to give the user a visual effect
setTimeout(() => { // // that the content is being cleared.
setClearingContentCache(false); // setTimeout(() => {
setContentCacheCleared(true); // setClearingContentCache(false);
}, 2000); // setContentCacheCleared(true);
}, [setClearingContentCache, clearContentCache, setContentCacheCleared]); // }, 2000);
// }, [setClearingContentCache, clearContentCache, setContentCacheCleared]);
return ( return (
<> <>
@ -118,30 +119,31 @@ export default function SettingContent(props: Props) {
checked={hideReposts} checked={hideReposts}
/> />
</SettingsRow> </SettingsRow>
<SettingsRow title={__('Persist watch time')} subtitle={__(HELP.PERSIST_WATCH_TIME)}> <SettingsRow title={__('Show Video View Progress')} subtitle={__(HELP.PERSIST_WATCH_TIME)}>
<div className="settings__persistWatchTimeCheckbox"> {/* <div className="settings__persistWatchTimeCheckbox"> */}
<FormField <FormField
type="checkbox" type="checkbox"
name="persist_watch_time" name="persist_watch_time"
onChange={() => setClientSetting(SETTINGS.PERSIST_WATCH_TIME, !persistWatchTime)} onChange={() => setClientSetting(SETTINGS.PERSIST_WATCH_TIME, !persistWatchTime)}
checked={persistWatchTime} checked={persistWatchTime}
/> />
</div> {/* </div> */}
<div className="settings__persistWatchTimeClearCache"> {/* Disabled until styling is better */}
<Button {/* <div className="settings__persistWatchTimeClearCache"> */}
button="primary" {/* <Button */}
icon={ICONS.ALERT} {/* button="primary" */}
label={ {/* icon={ICONS.ALERT} */}
contentCacheCleared {/* label={ */}
? __('Views cleared') {/* contentCacheCleared */}
: clearingContentCache {/* ? __('Views cleared') */}
? __('Clearing...') {/* : clearingContentCache */}
: __('Clear Views') {/* ? __('Clearing...') */}
} {/* : __('Clear Views') */}
onClick={onClearContentCache} {/* } */}
disabled={clearingContentCache || contentCacheCleared} {/* onClick={onClearContentCache} */}
/> {/* disabled={clearingContentCache || contentCacheCleared} */}
</div> {/* /> */}
{/* </div> */}
</SettingsRow> </SettingsRow>
<SettingsRow title={__('Show mature content')} subtitle={__(HELP.SHOW_MATURE)}> <SettingsRow title={__('Show mature content')} subtitle={__(HELP.SHOW_MATURE)}>
<FormField <FormField
@ -229,7 +231,7 @@ const HELP = {
AUTOPLAY_MEDIA: 'Autoplay video and audio files when navigating to a file.', AUTOPLAY_MEDIA: 'Autoplay video and audio files when navigating to a file.',
AUTOPLAY_NEXT: 'Autoplay the next related item when a file (video or audio) finishes playing.', AUTOPLAY_NEXT: 'Autoplay the next related item when a file (video or audio) finishes playing.',
HIDE_REPOSTS: 'You will not see reposts by people you follow or receive email notifying about them.', HIDE_REPOSTS: 'You will not see reposts by people you follow or receive email notifying about them.',
PERSIST_WATCH_TIME: 'Persist the watch time of the videos you have fully. This will not erase or hide any blockchain activity or downloads.', PERSIST_WATCH_TIME: 'Display view progress on thumbnail. This setting will not hide any blockchain activity or downloads.',
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. ', 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.', 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.", 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.",

View file

@ -5,7 +5,6 @@
width: 100%; width: 100%;
height: 5px; height: 5px;
background-color: var(--color-gray-7); background-color: var(--color-gray-7);
opacity: 0.5;
} }
.file-thumbnail__viewed-bar-progress { .file-thumbnail__viewed-bar-progress {

View file

@ -27,4 +27,5 @@
.settings__persistWatchTimeCheckbox { .settings__persistWatchTimeCheckbox {
text-align: right; text-align: right;
padding-top: var(--spacing-m);
} }