Fix broken player state when app is updated and resize failed

This commit is contained in:
Rafael 2022-04-26 16:53:59 -03:00 committed by Thomas Zarebczan
parent 7a86d7a895
commit 62fecf0403

View file

@ -139,6 +139,7 @@ export default function FileRenderFloating(props: Props) {
y: window.innerHeight - 400, y: window.innerHeight - 400,
}); });
const relativePosRef = React.useRef({ x: 0, y: 0 }); const relativePosRef = React.useRef({ x: 0, y: 0 });
const noPlayerHeight = fileViewerRect?.height === 0;
const navigateUrl = const navigateUrl =
(playingPrimaryUri || playingUrl || '') + (collectionId ? generateListSearchUrlParams(collectionId) : ''); (playingPrimaryUri || playingUrl || '') + (collectionId ? generateListSearchUrlParams(collectionId) : '');
@ -244,10 +245,10 @@ export default function FileRenderFloating(props: Props) {
}, [channelUrl, claimId, doCommentSocketConnect, doCommentSocketDisconnect, isCurrentClaimLive, uri]); }, [channelUrl, claimId, doCommentSocketConnect, doCommentSocketDisconnect, isCurrentClaimLive, uri]);
React.useEffect(() => { React.useEffect(() => {
if (playingPrimaryUri || playingUrl) { if (playingPrimaryUri || playingUrl || noPlayerHeight) {
handleResize(); handleResize();
} }
}, [handleResize, playingPrimaryUri, theaterMode, playingUrl]); }, [handleResize, playingPrimaryUri, theaterMode, playingUrl, noPlayerHeight]);
// Listen to main-window resizing and adjust the floating player position accordingly: // Listen to main-window resizing and adjust the floating player position accordingly:
React.useEffect(() => { React.useEffect(() => {
@ -587,7 +588,8 @@ const PlayerGlobalStyles = (props: GlobalStylesProps) => {
<Global <Global
styles={{ styles={{
[`.${PRIMARY_PLAYER_WRAPPER_CLASS}`]: { [`.${PRIMARY_PLAYER_WRAPPER_CLASS}`]: {
height: !theaterMode && mainFilePlaying ? `${heightResult} !important` : undefined, height:
!theaterMode && mainFilePlaying && fileViewerRect?.height > 0 ? `${heightResult} !important` : undefined,
opacity: !theaterMode && mainFilePlaying ? '0 !important' : undefined, opacity: !theaterMode && mainFilePlaying ? '0 !important' : undefined,
}, },