Re-fix layout shift
This commit is contained in:
parent
fa1cfc4882
commit
57ff910bbb
3 changed files with 33 additions and 12 deletions
|
@ -14,6 +14,7 @@ import Nag from 'component/common/nag';
|
||||||
// $FlowFixMe cannot resolve ...
|
// $FlowFixMe cannot resolve ...
|
||||||
import FileRenderPlaceholder from 'static/img/fileRenderPlaceholder.png';
|
import FileRenderPlaceholder from 'static/img/fileRenderPlaceholder.png';
|
||||||
import * as COLLECTIONS_CONSTS from 'constants/collections';
|
import * as COLLECTIONS_CONSTS from 'constants/collections';
|
||||||
|
import { LayoutRenderContext } from 'page/livestream/view';
|
||||||
import { formatLbryUrlForWeb } from 'util/url';
|
import { formatLbryUrlForWeb } from 'util/url';
|
||||||
import FileViewerEmbeddedTitle from 'component/fileViewerEmbeddedTitle';
|
import FileViewerEmbeddedTitle from 'component/fileViewerEmbeddedTitle';
|
||||||
import useFetchLiveStatus from 'effects/use-fetch-live';
|
import useFetchLiveStatus from 'effects/use-fetch-live';
|
||||||
|
@ -72,6 +73,8 @@ export default function FileRenderInitiator(props: Props) {
|
||||||
doFetchChannelLiveStatus,
|
doFetchChannelLiveStatus,
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
|
const layountRendered = React.useContext(LayoutRenderContext);
|
||||||
|
|
||||||
const isMobile = useIsMobile();
|
const isMobile = useIsMobile();
|
||||||
|
|
||||||
const containerRef = React.useRef<any>();
|
const containerRef = React.useRef<any>();
|
||||||
|
@ -87,7 +90,9 @@ export default function FileRenderInitiator(props: Props) {
|
||||||
const shouldAutoplay = !embedded && (forceAutoplayParam || urlTimeParam || autoplay);
|
const shouldAutoplay = !embedded && (forceAutoplayParam || urlTimeParam || autoplay);
|
||||||
|
|
||||||
const isFree = costInfo && costInfo.cost === 0;
|
const isFree = costInfo && costInfo.cost === 0;
|
||||||
const canViewFile = isLivestreamClaim ? isCurrentClaimLive : isFree || claimWasPurchased;
|
const canViewFile = isLivestreamClaim
|
||||||
|
? (layountRendered || isMobile) && isCurrentClaimLive
|
||||||
|
: isFree || claimWasPurchased;
|
||||||
const isPlayable = RENDER_MODES.FLOATING_MODES.includes(renderMode) || isCurrentClaimLive;
|
const isPlayable = RENDER_MODES.FLOATING_MODES.includes(renderMode) || isCurrentClaimLive;
|
||||||
const isText = RENDER_MODES.TEXT_MODES.includes(renderMode);
|
const isText = RENDER_MODES.TEXT_MODES.includes(renderMode);
|
||||||
|
|
||||||
|
|
|
@ -52,6 +52,7 @@ type Props = {
|
||||||
doSuperChatList: (uri: string) => void,
|
doSuperChatList: (uri: string) => void,
|
||||||
claimsByUri: { [string]: any },
|
claimsByUri: { [string]: any },
|
||||||
doFetchUserMemberships: (claimIdCsv: string) => void,
|
doFetchUserMemberships: (claimIdCsv: string) => void,
|
||||||
|
setLayountRendered: (boolean) => void,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function LivestreamChatLayout(props: Props) {
|
export default function LivestreamChatLayout(props: Props) {
|
||||||
|
@ -73,6 +74,7 @@ export default function LivestreamChatLayout(props: Props) {
|
||||||
doSuperChatList,
|
doSuperChatList,
|
||||||
doFetchUserMemberships,
|
doFetchUserMemberships,
|
||||||
claimsByUri,
|
claimsByUri,
|
||||||
|
setLayountRendered,
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
const isMobile = useIsMobile() && !isPopoutWindow;
|
const isMobile = useIsMobile() && !isPopoutWindow;
|
||||||
|
@ -167,6 +169,10 @@ export default function LivestreamChatLayout(props: Props) {
|
||||||
if (setCustomViewMode) setCustomViewMode(VIEW_MODES.SUPERCHAT);
|
if (setCustomViewMode) setCustomViewMode(VIEW_MODES.SUPERCHAT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
React.useEffect(() => {
|
||||||
|
if (setLayountRendered) setLayountRendered(true);
|
||||||
|
}, [setLayountRendered]);
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
if (customViewMode && customViewMode !== viewMode) {
|
if (customViewMode && customViewMode !== viewMode) {
|
||||||
setViewMode(customViewMode);
|
setViewMode(customViewMode);
|
||||||
|
|
|
@ -7,6 +7,7 @@ import LivestreamLayout from 'component/livestreamLayout';
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
import Page from 'component/page';
|
import Page from 'component/page';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import { useIsMobile } from 'effects/use-screensize';
|
||||||
import useFetchLiveStatus from 'effects/use-fetch-live';
|
import useFetchLiveStatus from 'effects/use-fetch-live';
|
||||||
|
|
||||||
const LivestreamChatLayout = lazyImport(() => import('component/livestreamChatLayout' /* webpackChunkName: "chat" */));
|
const LivestreamChatLayout = lazyImport(() => import('component/livestreamChatLayout' /* webpackChunkName: "chat" */));
|
||||||
|
@ -26,6 +27,8 @@ type Props = {
|
||||||
doUserSetReferrer: (string) => void,
|
doUserSetReferrer: (string) => void,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const LayoutRenderContext = React.createContext<any>();
|
||||||
|
|
||||||
export default function LivestreamPage(props: Props) {
|
export default function LivestreamPage(props: Props) {
|
||||||
const {
|
const {
|
||||||
activeLivestreamForChannel,
|
activeLivestreamForChannel,
|
||||||
|
@ -42,10 +45,13 @@ export default function LivestreamPage(props: Props) {
|
||||||
doUserSetReferrer,
|
doUserSetReferrer,
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
|
const isMobile = useIsMobile();
|
||||||
|
|
||||||
const [activeStreamUri, setActiveStreamUri] = React.useState(false);
|
const [activeStreamUri, setActiveStreamUri] = React.useState(false);
|
||||||
const [showLivestream, setShowLivestream] = React.useState(false);
|
const [showLivestream, setShowLivestream] = React.useState(false);
|
||||||
const [showScheduledInfo, setShowScheduledInfo] = React.useState(false);
|
const [showScheduledInfo, setShowScheduledInfo] = React.useState(false);
|
||||||
const [hideComments, setHideComments] = React.useState(false);
|
const [hideComments, setHideComments] = React.useState(false);
|
||||||
|
const [layountRendered, setLayountRendered] = React.useState(chatDisabled || isMobile);
|
||||||
|
|
||||||
const isInitialized = Boolean(activeLivestreamForChannel) || activeLivestreamInitialized;
|
const isInitialized = Boolean(activeLivestreamForChannel) || activeLivestreamInitialized;
|
||||||
const isChannelBroadcasting = Boolean(activeLivestreamForChannel);
|
const isChannelBroadcasting = Boolean(activeLivestreamForChannel);
|
||||||
|
@ -148,10 +154,12 @@ export default function LivestreamPage(props: Props) {
|
||||||
}, [uri, stringifiedClaim, isAuthenticated, doUserSetReferrer]);
|
}, [uri, stringifiedClaim, isAuthenticated, doUserSetReferrer]);
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
|
if (!layountRendered) return;
|
||||||
|
|
||||||
doSetPrimaryUri(uri);
|
doSetPrimaryUri(uri);
|
||||||
|
|
||||||
return () => doSetPrimaryUri(null);
|
return () => doSetPrimaryUri(null);
|
||||||
}, [doSetPrimaryUri, uri]);
|
}, [doSetPrimaryUri, layountRendered, uri]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Page
|
<Page
|
||||||
|
@ -163,21 +171,23 @@ export default function LivestreamPage(props: Props) {
|
||||||
!hideComments &&
|
!hideComments &&
|
||||||
isInitialized && (
|
isInitialized && (
|
||||||
<React.Suspense fallback={null}>
|
<React.Suspense fallback={null}>
|
||||||
<LivestreamChatLayout uri={uri} />
|
<LivestreamChatLayout uri={uri} setLayountRendered={setLayountRendered} />
|
||||||
</React.Suspense>
|
</React.Suspense>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
{isInitialized && (
|
{isInitialized && (
|
||||||
<LivestreamLayout
|
<LayoutRenderContext.Provider value={layountRendered}>
|
||||||
uri={uri}
|
<LivestreamLayout
|
||||||
hideComments={hideComments}
|
uri={uri}
|
||||||
release={release}
|
hideComments={hideComments}
|
||||||
isCurrentClaimLive={isCurrentClaimLive}
|
release={release}
|
||||||
showLivestream={showLivestream}
|
isCurrentClaimLive={isCurrentClaimLive}
|
||||||
showScheduledInfo={showScheduledInfo}
|
showLivestream={showLivestream}
|
||||||
activeStreamUri={activeStreamUri}
|
showScheduledInfo={showScheduledInfo}
|
||||||
/>
|
activeStreamUri={activeStreamUri}
|
||||||
|
/>
|
||||||
|
</LayoutRenderContext.Provider>
|
||||||
)}
|
)}
|
||||||
</Page>
|
</Page>
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Reference in a new issue