add review changes

This commit is contained in:
jessop 2020-01-27 16:37:54 -05:00 committed by Sean Yesmunt
parent 33672a789b
commit 3e40838ae3
4 changed files with 20 additions and 25 deletions

View file

@ -31,7 +31,7 @@ type Props = {
mediaType: string, mediaType: string,
isText: true, isText: true,
streamingUrl: string, streamingUrl: string,
embedUrl?: string, embedded?: boolean,
contentType: string, contentType: string,
claim: StreamClaim, claim: StreamClaim,
currentTheme: string, currentTheme: string,
@ -103,23 +103,12 @@ class FileRender extends React.PureComponent<Props, State> {
} }
renderViewer() { renderViewer() {
const { const { mediaType, currentTheme, claim, contentType, downloadPath, fileName, streamingUrl, uri } = this.props;
mediaType,
currentTheme,
claim,
contentType,
downloadPath,
fileName,
streamingUrl,
embedUrl,
uri,
} = this.props;
const fileType = fileName && path.extname(fileName).substring(1); const fileType = fileName && path.extname(fileName).substring(1);
const streamUrl = embedUrl || streamingUrl;
// Ideally the lbrytv api server would just replace the streaming_url returned by the sdk so we don't need this check // Ideally the lbrytv api server would just replace the streaming_url returned by the sdk so we don't need this check
// https://github.com/lbryio/lbrytv/issues/51 // https://github.com/lbryio/lbrytv/issues/51
const source = IS_WEB ? generateStreamUrl(claim.name, claim.claim_id) : streamUrl; const source = IS_WEB ? generateStreamUrl(claim.name, claim.claim_id) : streamingUrl;
// Human-readable files (scripts and plain-text files) // Human-readable files (scripts and plain-text files)
const readableFiles = ['text', 'document', 'script']; const readableFiles = ['text', 'document', 'script'];
@ -221,11 +210,17 @@ class FileRender extends React.PureComponent<Props, State> {
return viewer || unsupported; return viewer || unsupported;
} }
render() { render() {
const { isText, uri, currentlyFloating } = this.props; const { isText, uri, currentlyFloating, embedded } = this.props;
const { showAutoplayCountdown } = this.state; const { showAutoplayCountdown } = this.state;
return ( return (
<div className={classnames('file-render', { 'file-render--document': isText })}> <div
className={classnames({
'file-render': !embedded,
'file-render--document': isText && !embedded,
'file-render__embed': embedded,
})}
>
{!currentlyFloating && showAutoplayCountdown && <AutoplayCountdown uri={uri} />} {!currentlyFloating && showAutoplayCountdown && <AutoplayCountdown uri={uri} />}
<Suspense fallback={<div />}>{this.renderViewer()}</Suspense> <Suspense fallback={<div />}>{this.renderViewer()}</Suspense>
</div> </div>

View file

@ -1,18 +1,15 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import EmbedWrapperPage from './view'; import EmbedWrapperPage from './view';
import { doResolveUri, makeSelectClaimForUri } from 'lbry-redux'; import { doResolveUri, makeSelectClaimForUri, buildURI } from 'lbry-redux';
import { generateStreamUrl } from 'util/lbrytv';
const select = (state, props) => { const select = (state, props) => {
const PROTOCOL = 'lbry://';
const { match } = props; const { match } = props;
const { params } = match; const { params } = match;
const { claimName, claimId } = params; const { claimName, claimId } = params;
const uri = PROTOCOL + claimName + (claimId ? `#${claimId}` : ''); const uri = claimName && claimId ? buildURI({ claimName, claimId }) : '';
return { return {
uri, uri,
claim: makeSelectClaimForUri(uri)(state), claim: makeSelectClaimForUri(uri)(state),
streamUrl: generateStreamUrl(claimName, claimId),
}; };
}; };

View file

@ -7,10 +7,9 @@ type Props = {
uri: string, uri: string,
resolveUri: string => void, resolveUri: string => void,
claim: Claim, claim: Claim,
streamUrl: string,
}; };
const EmbedWrapperPage = (props: Props) => { const EmbedWrapperPage = (props: Props) => {
const { resolveUri, claim, uri, streamUrl } = props; const { resolveUri, claim, uri } = props;
useEffect(() => { useEffect(() => {
if (resolveUri && uri) { if (resolveUri && uri) {
resolveUri(uri); resolveUri(uri);
@ -20,7 +19,7 @@ const EmbedWrapperPage = (props: Props) => {
if (uri && claim) { if (uri && claim) {
return ( return (
<div className={'embed__wrapper'}> <div className={'embed__wrapper'}>
<FileRender uri={uri} embedUrl={streamUrl} /> <FileRender uri={uri} embedded />
</div> </div>
); );
} else { } else {

View file

@ -49,9 +49,9 @@ const defaultState: AppState = {
daemonReady: false, daemonReady: false,
hasSignature: false, hasSignature: false,
badgeNumber: 0, badgeNumber: 0,
volume: 1,
// @if TARGET='app' // @if TARGET='app'
upgradeSkipped: sessionStorage.getItem('upgradeSkipped') === 'true', upgradeSkipped: sessionStorage.getItem('upgradeSkipped') === 'true',
volume: Number(sessionStorage.getItem('volume')) || 1,
// @endif // @endif
muted: false, muted: false,
autoUpdateDownloaded: false, autoUpdateDownloaded: false,
@ -73,6 +73,10 @@ const defaultState: AppState = {
// @@router comes from react-router // @@router comes from react-router
// This action is dispatched any time a user navigates forward or back // This action is dispatched any time a user navigates forward or back
try {
defaultState.volume = Number(sessionStorage.getItem('volume'));
} catch (e) {}
reducers['@@router/LOCATION_CHANGE'] = (state, action) => { reducers['@@router/LOCATION_CHANGE'] = (state, action) => {
const { currentScroll } = state; const { currentScroll } = state;
const scrollHistory = (state.scrollHistory && state.scrollHistory.slice()) || []; const scrollHistory = (state.scrollHistory && state.scrollHistory.slice()) || [];