Fix layout shift
This commit is contained in:
parent
04c5ac460b
commit
9ac64eb6a7
4 changed files with 24 additions and 40 deletions
|
@ -14,7 +14,6 @@ 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';
|
||||||
|
@ -73,8 +72,6 @@ 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>();
|
||||||
|
@ -90,9 +87,7 @@ 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
|
const canViewFile = isLivestreamClaim ? isCurrentClaimLive : isFree || claimWasPurchased;
|
||||||
? (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,7 +52,6 @@ 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) {
|
||||||
|
@ -74,7 +73,6 @@ export default function LivestreamChatLayout(props: Props) {
|
||||||
doSuperChatList,
|
doSuperChatList,
|
||||||
doFetchUserMemberships,
|
doFetchUserMemberships,
|
||||||
claimsByUri,
|
claimsByUri,
|
||||||
setLayountRendered,
|
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
const isMobile = useIsMobile() && !isPopoutWindow;
|
const isMobile = useIsMobile() && !isPopoutWindow;
|
||||||
|
@ -169,10 +167,6 @@ 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,7 +7,6 @@ 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" */));
|
||||||
|
@ -27,8 +26,6 @@ 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,
|
||||||
|
@ -45,13 +42,10 @@ 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);
|
||||||
|
@ -154,12 +148,10 @@ 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, layountRendered, uri]);
|
}, [doSetPrimaryUri, uri]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Page
|
<Page
|
||||||
|
@ -171,23 +163,21 @@ export default function LivestreamPage(props: Props) {
|
||||||
!hideComments &&
|
!hideComments &&
|
||||||
isInitialized && (
|
isInitialized && (
|
||||||
<React.Suspense fallback={null}>
|
<React.Suspense fallback={null}>
|
||||||
<LivestreamChatLayout uri={uri} setLayountRendered={setLayountRendered} />
|
<LivestreamChatLayout uri={uri} />
|
||||||
</React.Suspense>
|
</React.Suspense>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
{isInitialized && (
|
{isInitialized && (
|
||||||
<LayoutRenderContext.Provider value={layountRendered}>
|
<LivestreamLayout
|
||||||
<LivestreamLayout
|
uri={uri}
|
||||||
uri={uri}
|
hideComments={hideComments}
|
||||||
hideComments={hideComments}
|
release={release}
|
||||||
release={release}
|
isCurrentClaimLive={isCurrentClaimLive}
|
||||||
isCurrentClaimLive={isCurrentClaimLive}
|
showLivestream={showLivestream}
|
||||||
showLivestream={showLivestream}
|
showScheduledInfo={showScheduledInfo}
|
||||||
showScheduledInfo={showScheduledInfo}
|
activeStreamUri={activeStreamUri}
|
||||||
activeStreamUri={activeStreamUri}
|
/>
|
||||||
/>
|
|
||||||
</LayoutRenderContext.Provider>
|
|
||||||
)}
|
)}
|
||||||
</Page>
|
</Page>
|
||||||
);
|
);
|
||||||
|
|
|
@ -580,18 +580,23 @@ body {
|
||||||
|
|
||||||
@media (min-width: 1750px) {
|
@media (min-width: 1750px) {
|
||||||
padding: 0;
|
padding: 0;
|
||||||
|
width: 100%;
|
||||||
|
max-width: var(--page-max-width--filepage);
|
||||||
|
position: relative;
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 1fr minmax(0, var(--livestream-comments-width));
|
||||||
|
justify-content: space-between;
|
||||||
|
justify-items: end;
|
||||||
|
gap: var(--spacing-m);
|
||||||
|
|
||||||
|
.livestream__chat {
|
||||||
|
margin: 0 !important;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.card-stack {
|
.card-stack {
|
||||||
margin-bottom: var(--spacing-m);
|
margin-bottom: var(--spacing-m);
|
||||||
|
|
||||||
@media (min-width: ($breakpoint-large + 300px)) {
|
|
||||||
max-width: calc(var(--page-max-width--filepage) / 1.25);
|
|
||||||
margin-left: auto;
|
|
||||||
margin-right: auto;
|
|
||||||
width: calc(100% - var(--livestream-comments-width));
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (max-width: $breakpoint-medium) {
|
@media (max-width: $breakpoint-medium) {
|
||||||
max-width: none;
|
max-width: none;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue