fix autoplay

This commit is contained in:
Sean Yesmunt 2020-05-26 13:11:01 -04:00
parent a7812350ce
commit f64e659a7c
2 changed files with 17 additions and 12 deletions

View file

@ -4,7 +4,7 @@ import { makeSelectClaimForUri } from 'lbry-redux';
import { withRouter } from 'react-router'; import { withRouter } from 'react-router';
import { makeSelectIsPlayerFloating, makeSelectNextUnplayedRecommended } from 'redux/selectors/content'; import { makeSelectIsPlayerFloating, makeSelectNextUnplayedRecommended } from 'redux/selectors/content';
import { makeSelectClientSetting } from 'redux/selectors/settings'; import { makeSelectClientSetting } from 'redux/selectors/settings';
import { doSetPlayingUri } from 'redux/actions/content'; import { doSetPlayingUri, doPlayUri } from 'redux/actions/content';
import AutoplayCountdown from './view'; import AutoplayCountdown from './view';
/* /*
@ -20,8 +20,9 @@ const select = (state, props) => {
}; };
}; };
const perform = dispatch => ({ export default withRouter(
setPlayingUri: uri => dispatch(doSetPlayingUri(uri)), connect(select, {
}); doSetPlayingUri,
doPlayUri,
export default withRouter(connect(select, perform)(AutoplayCountdown)); })(AutoplayCountdown)
);

View file

@ -11,14 +11,16 @@ type Props = {
nextRecommendedClaim: ?StreamClaim, nextRecommendedClaim: ?StreamClaim,
nextRecommendedUri: string, nextRecommendedUri: string,
isFloating: boolean, isFloating: boolean,
setPlayingUri: (string | null) => void, doSetPlayingUri: (string | null) => void,
doPlayUri: string => void,
}; };
function AutoplayCountdown(props: Props) { function AutoplayCountdown(props: Props) {
const { const {
nextRecommendedUri, nextRecommendedUri,
nextRecommendedClaim, nextRecommendedClaim,
setPlayingUri, doSetPlayingUri,
doPlayUri,
isFloating, isFloating,
history: { push }, history: { push },
} = props; } = props;
@ -39,14 +41,16 @@ function AutoplayCountdown(props: Props) {
if (!isFloating) { if (!isFloating) {
if (navigateUrl) { if (navigateUrl) {
push(navigateUrl); push(navigateUrl);
setPlayingUri(nextRecommendedUri); doSetPlayingUri(nextRecommendedUri);
doPlayUri(nextRecommendedUri);
} }
} else { } else {
if (nextRecommendedUri) { if (nextRecommendedUri) {
setPlayingUri(nextRecommendedUri); doSetPlayingUri(nextRecommendedUri);
doPlayUri(nextRecommendedUri);
} }
} }
}, [navigateUrl, nextRecommendedUri, isFloating, setPlayingUri]); }, [navigateUrl, nextRecommendedUri, isFloating, doSetPlayingUri, doPlayUri]);
React.useEffect(() => { React.useEffect(() => {
let interval; let interval;
@ -63,7 +67,7 @@ function AutoplayCountdown(props: Props) {
return () => { return () => {
clearInterval(interval); clearInterval(interval);
}; };
}, [timer, doNavigate, navigateUrl, push, timerCanceled, setPlayingUri, nextRecommendedUri]); }, [timer, doNavigate, navigateUrl, push, timerCanceled, nextRecommendedUri]);
if (timerCanceled || !nextRecommendedUri) { if (timerCanceled || !nextRecommendedUri) {
return null; return null;