fix autoplay
This commit is contained in:
parent
a7812350ce
commit
f64e659a7c
2 changed files with 17 additions and 12 deletions
|
@ -4,7 +4,7 @@ import { makeSelectClaimForUri } from 'lbry-redux';
|
|||
import { withRouter } from 'react-router';
|
||||
import { makeSelectIsPlayerFloating, makeSelectNextUnplayedRecommended } from 'redux/selectors/content';
|
||||
import { makeSelectClientSetting } from 'redux/selectors/settings';
|
||||
import { doSetPlayingUri } from 'redux/actions/content';
|
||||
import { doSetPlayingUri, doPlayUri } from 'redux/actions/content';
|
||||
import AutoplayCountdown from './view';
|
||||
|
||||
/*
|
||||
|
@ -20,8 +20,9 @@ const select = (state, props) => {
|
|||
};
|
||||
};
|
||||
|
||||
const perform = dispatch => ({
|
||||
setPlayingUri: uri => dispatch(doSetPlayingUri(uri)),
|
||||
});
|
||||
|
||||
export default withRouter(connect(select, perform)(AutoplayCountdown));
|
||||
export default withRouter(
|
||||
connect(select, {
|
||||
doSetPlayingUri,
|
||||
doPlayUri,
|
||||
})(AutoplayCountdown)
|
||||
);
|
||||
|
|
|
@ -11,14 +11,16 @@ type Props = {
|
|||
nextRecommendedClaim: ?StreamClaim,
|
||||
nextRecommendedUri: string,
|
||||
isFloating: boolean,
|
||||
setPlayingUri: (string | null) => void,
|
||||
doSetPlayingUri: (string | null) => void,
|
||||
doPlayUri: string => void,
|
||||
};
|
||||
|
||||
function AutoplayCountdown(props: Props) {
|
||||
const {
|
||||
nextRecommendedUri,
|
||||
nextRecommendedClaim,
|
||||
setPlayingUri,
|
||||
doSetPlayingUri,
|
||||
doPlayUri,
|
||||
isFloating,
|
||||
history: { push },
|
||||
} = props;
|
||||
|
@ -39,14 +41,16 @@ function AutoplayCountdown(props: Props) {
|
|||
if (!isFloating) {
|
||||
if (navigateUrl) {
|
||||
push(navigateUrl);
|
||||
setPlayingUri(nextRecommendedUri);
|
||||
doSetPlayingUri(nextRecommendedUri);
|
||||
doPlayUri(nextRecommendedUri);
|
||||
}
|
||||
} else {
|
||||
if (nextRecommendedUri) {
|
||||
setPlayingUri(nextRecommendedUri);
|
||||
doSetPlayingUri(nextRecommendedUri);
|
||||
doPlayUri(nextRecommendedUri);
|
||||
}
|
||||
}
|
||||
}, [navigateUrl, nextRecommendedUri, isFloating, setPlayingUri]);
|
||||
}, [navigateUrl, nextRecommendedUri, isFloating, doSetPlayingUri, doPlayUri]);
|
||||
|
||||
React.useEffect(() => {
|
||||
let interval;
|
||||
|
@ -63,7 +67,7 @@ function AutoplayCountdown(props: Props) {
|
|||
return () => {
|
||||
clearInterval(interval);
|
||||
};
|
||||
}, [timer, doNavigate, navigateUrl, push, timerCanceled, setPlayingUri, nextRecommendedUri]);
|
||||
}, [timer, doNavigate, navigateUrl, push, timerCanceled, nextRecommendedUri]);
|
||||
|
||||
if (timerCanceled || !nextRecommendedUri) {
|
||||
return null;
|
||||
|
|
Loading…
Reference in a new issue