Dont show additional player buttons from markdown and comments

This commit is contained in:
saltrafael 2021-09-13 06:11:48 -03:00
parent 903a7c8afd
commit 37ce82edb4
No known key found for this signature in database
GPG key ID: 9C7F1DC0B0F54515
2 changed files with 56 additions and 67 deletions

View file

@ -1,7 +1,6 @@
import { connect } from 'react-redux';
import {
makeSelectClaimForUri,
makeSelectFileInfoForUri,
makeSelectThumbnailForUri,
SETTINGS,
COLLECTIONS_CONSTS,
@ -40,6 +39,7 @@ const select = (state, props) => {
const userId = selectUser(state) && selectUser(state).id;
const playingUri = selectPlayingUri(state);
const collectionId = urlParams.get(COLLECTIONS_CONSTS.COLLECTION_ID) || (playingUri && playingUri.collectionId);
const isMarkdownOrComment = playingUri && (playingUri.source === 'markdown' || playingUri.source === 'comment');
let nextRecommendedUri;
let previousListUri;
@ -51,24 +51,23 @@ const select = (state, props) => {
}
return {
position,
userId,
collectionId,
nextRecommendedUri,
previousListUri,
isMarkdownOrComment,
autoplayIfEmbedded: Boolean(autoplay),
autoplayMedia: Boolean(makeSelectClientSetting(SETTINGS.AUTOPLAY_MEDIA)(state)),
autoplayNext: Boolean(makeSelectClientSetting(SETTINGS.AUTOPLAY_NEXT)(state)),
autoplayNext: makeSelectClientSetting(SETTINGS.AUTOPLAY_NEXT)(state),
volume: selectVolume(state),
muted: selectMute(state),
videoPlaybackRate: makeSelectClientSetting(SETTINGS.VIDEO_PLAYBACK_RATE)(state),
position: position,
hasFileInfo: Boolean(makeSelectFileInfoForUri(uri)(state)),
thumbnail: makeSelectThumbnailForUri(uri)(state),
claim: makeSelectClaimForUri(uri)(state),
homepageData: selectHomepageData(state),
authenticated: selectUserVerifiedEmail(state),
userId: userId,
shareTelemetry: IS_WEB || selectDaemonSettings(state).share_usage_data,
isFloating: makeSelectIsPlayerFloating(props.location)(state),
collectionId,
nextRecommendedUri,
previousListUri,
videoTheaterMode: makeSelectClientSetting(SETTINGS.VIDEO_THEATER_MODE)(state),
};
};

View file

@ -42,7 +42,6 @@ type Props = {
videoPlaybackRate: number,
volume: number,
uri: string,
autoplayMedia: boolean,
autoplayNext: boolean,
autoplayIfEmbedded: boolean,
desktopPlayStartTime?: number,
@ -64,6 +63,7 @@ type Props = {
nextRecommendedUri: string,
previousListUri: string,
videoTheaterMode: boolean,
isMarkdownOrComment: boolean,
};
/*
@ -84,7 +84,6 @@ function VideoViewer(props: Props) {
uri,
muted,
volume,
autoplayMedia,
autoplayNext,
autoplayIfEmbedded,
doAnalyticsView,
@ -106,6 +105,7 @@ function VideoViewer(props: Props) {
nextRecommendedUri,
previousListUri,
videoTheaterMode,
isMarkdownOrComment,
} = props;
const permanentUrl = claim && claim.permanent_url;
const adApprovedChannelIds = homepageData ? getAllIds(homepageData) : [];
@ -196,32 +196,32 @@ function VideoViewer(props: Props) {
);
useEffect(() => {
if (doNavigate) {
if (playNextUrl) {
if (permanentUrl !== nextRecommendedUri) {
if (nextRecommendedUri) {
if (collectionId) clearPosition(permanentUrl);
doPlay(nextRecommendedUri);
}
} else {
setReplay(true);
if (!doNavigate) return;
if (playNextUrl) {
if (permanentUrl !== nextRecommendedUri) {
if (nextRecommendedUri) {
if (collectionId) clearPosition(permanentUrl);
doPlay(nextRecommendedUri);
}
} else {
if (videoNode) {
const currentTime = videoNode.currentTime;
if (currentTime <= 5) {
if (previousListUri && permanentUrl !== previousListUri) doPlay(previousListUri);
} else {
videoNode.currentTime = 0;
}
setDoNavigate(false);
}
setReplay(true);
}
} else {
if (videoNode) {
const currentTime = videoNode.currentTime;
if (currentTime <= 5) {
if (previousListUri && permanentUrl !== previousListUri) doPlay(previousListUri);
} else {
videoNode.currentTime = 0;
}
setDoNavigate(false);
}
if (!ended) setDoNavigate(false);
setEnded(false);
setPlayNextUrl(true);
}
if (!ended) setDoNavigate(false);
setEnded(false);
setPlayNextUrl(true);
}, [
clearPosition,
collectionId,
@ -236,37 +236,25 @@ function VideoViewer(props: Props) {
]);
React.useEffect(() => {
if (ended) {
analytics.videoIsPlaying(false);
if (!ended) return;
if (adUrl) {
setAdUrl(null);
return;
}
analytics.videoIsPlaying(false);
if (embedded) {
setIsEndedEmbed(true);
} else if (!collectionId && autoplayNext) {
setShowAutoplayCountdown(true);
} else if (collectionId) {
setDoNavigate(true);
}
clearPosition(uri);
if (adUrl) {
setAdUrl(null);
return;
}
}, [
embedded,
setIsEndedEmbed,
autoplayMedia,
setShowAutoplayCountdown,
adUrl,
setAdUrl,
clearPosition,
uri,
ended,
collectionId,
autoplayNext,
]);
if (embedded) {
setIsEndedEmbed(true);
} else if (!collectionId && autoplayNext) {
setShowAutoplayCountdown(true);
} else if (collectionId) {
setDoNavigate(true);
}
clearPosition(uri);
}, [adUrl, autoplayNext, clearPosition, collectionId, embedded, ended, setAdUrl, uri]);
function onPlay(player) {
setEnded(false);
@ -321,12 +309,14 @@ function VideoViewer(props: Props) {
player.muted(muted);
player.volume(volume);
player.playbackRate(videoPlaybackRate);
addTheaterModeButton(player, toggleVideoTheaterMode);
if (collectionId) {
addPlayNextButton(player, doPlayNext);
addPlayPreviousButton(player, doPlayPrevious);
} else {
addAutoplayNextButton(player, toggleAutoplayNext, autoplayNext);
if (!isMarkdownOrComment) {
addTheaterModeButton(player, toggleVideoTheaterMode);
if (collectionId) {
addPlayNextButton(player, doPlayNext);
addPlayPreviousButton(player, doPlayPrevious);
} else {
addAutoplayNextButton(player, toggleAutoplayNext, autoplayNext);
}
}
}