diff --git a/package-lock.json b/package-lock.json index 93be683..925284e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10128,12 +10128,9 @@ } }, "react-navigation-drawer": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/react-navigation-drawer/-/react-navigation-drawer-1.4.0.tgz", - "integrity": "sha512-ZyWBozcjB2aZ7vwCALv90cYA2NpDjM+WALaiYRshvPvue8l7cqynePbHK8GhlMGyJDwZqp4MxQmu8u1XAKp3Bw==", - "requires": { - "react-native-tab-view": "^1.2.0" - } + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/react-navigation-drawer/-/react-navigation-drawer-2.3.3.tgz", + "integrity": "sha512-d/rA8Slqv7HoMfONKVDBQUrRF7YQH796Gzal/KOhaY4VOwUUqIwfxMRJ3WrsdL2OkDPixtkXJE2Fz6KAj658uA==" }, "react-navigation-redux-helpers": { "version": "3.0.2", diff --git a/package.json b/package.json index f4e561a..553fc77 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "react-native-vector-icons": "^6.6.0", "react-native-video": "lbryio/react-native-video#7992ff945872f9bd00a3736d9ff1318f343abf47", "react-navigation": "^3.11.0", - "react-navigation-drawer": "^1.4.0", + "react-navigation-drawer": "^2.3.3", "react-navigation-redux-helpers": "^3.0.2", "react-navigation-stack": "^1.8.1", "react-redux": "^5.0.3", diff --git a/src/component/relatedContent/index.js b/src/component/relatedContent/index.js index 6cb46de..7dd415c 100644 --- a/src/component/relatedContent/index.js +++ b/src/component/relatedContent/index.js @@ -1,27 +1,25 @@ import { connect } from 'react-redux'; import { doResolveUris, - doSearch, makeSelectClaimForUri, makeSelectRecommendedContentForUri, - selectResolvingUris, + makeSelectTitleForUri, selectIsSearching, } from 'lbry-redux'; import RelatedContent from './view'; const select = (state, props) => ({ claim: makeSelectClaimForUri(props.uri)(state), - isSearching: selectIsSearching(state), recommendedContent: makeSelectRecommendedContentForUri(props.uri)(state), - resolvingUris: selectResolvingUris(state), + title: makeSelectTitleForUri(props.uri)(state), + isSearching: selectIsSearching(state), }); const perform = dispatch => ({ resolveUris: uris => dispatch(doResolveUris(uris)), - searchRecommended: query => dispatch(doSearch(query, 20, undefined, true)), }); export default connect( select, - perform, + perform )(RelatedContent); diff --git a/src/component/relatedContent/view.js b/src/component/relatedContent/view.js index 639587c..8f626f8 100644 --- a/src/component/relatedContent/view.js +++ b/src/component/relatedContent/view.js @@ -8,54 +8,20 @@ import fileListStyle from 'styles/fileList'; import relatedContentStyle from 'styles/relatedContent'; export default class RelatedContent extends React.PureComponent { - state = { - resolveStarted: false, - }; - componentDidMount() { - const { title, searchRecommended } = this.props; - if (title) { - searchRecommended(title); - } - } - - shouldComponentUpdate(nextProps, nextState) { - const { isSearching, recommendedContent } = nextProps; - return isSearching || (!isSearching && this.allContentResolved()); - } - - allContentResolved() { - const { recommendedContent, resolvingUris } = this.props; - if (recommendedContent) { - let allResolved = true; - recommendedContent.forEach(uri => { - allResolved = allResolved && !resolvingUris.includes(uri); - }); - return allResolved; - } - - return false; - } - - componentDidUpdate() { const { resolveUris, recommendedContent } = this.props; - if (!this.state.resolveStarted) { - this.setState({ resolveStarted: true }, () => { - if (recommendedContent && recommendedContent.length > 0) { - // batch resolve the uris - resolveUris(recommendedContent); - } - }); + if (recommendedContent && recommendedContent.length > 0) { + // batch resolve the uris + resolveUris(recommendedContent); } } render() { - const { isSearching, recommendedContent, navigation, uri, fullUri } = this.props; + const { recommendedContent, navigation, uri, fullUri } = this.props; return ( {__('Related Content')} - {isSearching && } {recommendedContent && recommendedContent .filter(recommendedUri => recommendedUri !== normalizeURI(fullUri)) diff --git a/src/page/file/index.js b/src/page/file/index.js index 099079a..36dd480 100644 --- a/src/page/file/index.js +++ b/src/page/file/index.js @@ -9,6 +9,7 @@ import { doDeletePurchasedUri, doResolveUri, doResolveUris, + doSearch, doSendTip, doToast, makeSelectIsUriResolving, @@ -18,6 +19,7 @@ import { makeSelectContentPositionForUri, makeSelectContentTypeForUri, makeSelectMetadataForUri, + makeSelectRecommendedContentForUri, makeSelectStreamingUrlForUri, makeSelectThumbnailForUri, makeSelectTitleForUri, @@ -27,6 +29,7 @@ import { selectPurchasedUris, selectFailedPurchaseUris, selectPurchaseUriErrorMessage, + selectResolvingUris, selectIsSearching, } from 'lbry-redux'; import { @@ -69,6 +72,8 @@ const select = (state, props) => { streamingUrl: makeSelectStreamingUrlForUri(contentUri)(state), thumbnail: makeSelectThumbnailForUri(contentUri)(state), title: makeSelectTitleForUri(contentUri)(state), + recommendedContent: makeSelectRecommendedContentForUri(contentUri)(state), + resolvingUris: selectResolvingUris(state), isSearchingRecommendContent: selectIsSearching(state), viewCount: makeSelectViewCountForUri(contentUri)(state), }; @@ -93,6 +98,7 @@ const perform = dispatch => ({ deletePurchasedUri: uri => dispatch(doDeletePurchasedUri(uri)), resolveUri: uri => dispatch(doResolveUri(uri)), resolveUris: uris => dispatch(doResolveUris(uris)), + searchRecommended: query => dispatch(doSearch(query, 20, undefined, true)), sendTip: (amount, claimId, isSupport, successCallback, errorCallback) => dispatch(doSendTip(amount, claimId, isSupport, successCallback, errorCallback)), setPlayerVisible: () => dispatch(doSetPlayerVisible(true)), @@ -102,5 +108,5 @@ const perform = dispatch => ({ export default connect( select, - perform, + perform )(FilePage); diff --git a/src/page/file/view.js b/src/page/file/view.js index 4f991d7..0cc1156 100644 --- a/src/page/file/view.js +++ b/src/page/file/view.js @@ -87,7 +87,6 @@ class FilePage extends React.PureComponent { playerHeight: 0, uri: null, uriVars: null, - showRecommended: false, stopDownloadConfirmed: false, streamingMode: false, viewCountFetched: false, @@ -340,7 +339,7 @@ class FilePage extends React.PureComponent { }, }, ], - { cancelable: true }, + { cancelable: true } ); }; @@ -376,7 +375,7 @@ class FilePage extends React.PureComponent { }, }, ], - { cancelable: true }, + { cancelable: true } ); }; @@ -525,6 +524,7 @@ class FilePage extends React.PureComponent { }; onPlaybackStarted = () => { + const { searchRecommended, title } = this.props; let timeToStartMillis, timeToStart; if (this.startTime) { timeToStartMillis = Date.now() - this.startTime; @@ -544,7 +544,9 @@ class FilePage extends React.PureComponent { NativeModules.Firebase.track('play', payload); // only fetch recommended content after playback has started - this.setState({ showRecommended: true }); + if (title) { + searchRecommended(title); + } }; onPlaybackFinished = () => { @@ -650,7 +652,7 @@ class FilePage extends React.PureComponent { () => { purchaseUri(claim.permanent_url, costInfo, true); NativeModules.UtilityModule.checkDownloads(); - }, + } ); }; @@ -687,7 +689,7 @@ class FilePage extends React.PureComponent { ], showImageViewer: true, }, - () => pushDrawerStack(Constants.DRAWER_ROUTE_FILE_VIEW), + () => pushDrawerStack(Constants.DRAWER_ROUTE_FILE_VIEW) ); } } @@ -698,7 +700,7 @@ class FilePage extends React.PureComponent { { showWebView: true, }, - () => pushDrawerStack(Constants.DRAWER_ROUTE_FILE_VIEW), + () => pushDrawerStack(Constants.DRAWER_ROUTE_FILE_VIEW) ); } } @@ -735,8 +737,6 @@ class FilePage extends React.PureComponent { const myChannelUris = channels ? channels.map(channel => channel.permanent_url) : []; const ownedClaim = myClaimUris.includes(uri) || myChannelUris.includes(uri); - console.log('calling render...'); - let innerContent = null; if ((isResolvingUri && !claim) || !claim) { return ( @@ -794,7 +794,7 @@ class FilePage extends React.PureComponent { {__( - 'In response to a complaint we received under the US Digital Millennium Copyright Act, we have blocked access to this content from our applications.', + 'In response to a complaint we received under the US Digital Millennium Copyright Act, we have blocked access to this content from our applications.' )} @@ -882,8 +882,6 @@ class FilePage extends React.PureComponent { return ( {!this.state.fullscreenMode && } - {innerContent} - {this.state.showWebView && isWebViewable && ( )} @@ -894,7 +892,7 @@ class FilePage extends React.PureComponent { renderIndicator={() => null} /> )} - {!innerContent && !this.state.showWebView && ( + {!this.state.showWebView && ( - {!innerContent && (this.state.streamingMode || (canLoadMedia && fileInfo && isPlayable)) && ( + {(this.state.streamingMode || (canLoadMedia && fileInfo && isPlayable)) && ( { @@ -972,10 +970,10 @@ class FilePage extends React.PureComponent { }} /> )} - {!innerContent && - (this.state.streamingMode || (canLoadMedia && fileInfo && isPlayable)) && - this.state.fullscreenMode && } - {!innerContent && (this.state.streamingMode || (canLoadMedia && fileInfo && isPlayable)) && ( + {(this.state.streamingMode || (canLoadMedia && fileInfo && isPlayable)) && this.state.fullscreenMode && ( + + )} + {(this.state.streamingMode || (canLoadMedia && fileInfo && isPlayable)) && ( { @@ -1000,194 +998,195 @@ class FilePage extends React.PureComponent { /> )} - {!innerContent && ( - { - this.scrollView = ref; - }} + { + this.scrollView = ref; + }} + > + this.setState({ showDescription: !this.state.showDescription })} > - this.setState({ showDescription: !this.state.showDescription })} - > - - - - {title} - - {isRewardContent && } - - - - - - {viewCount === 1 && __('%view% view', { view: viewCount })} - {viewCount > 1 && __('%view% views', { view: viewCount })} + + + + {title} + {isRewardContent && } + + + - + + {viewCount === 1 && __('%view% view', { view: viewCount })} + {viewCount > 1 && __('%view% views', { view: viewCount })} + + + - - - - {__('Share')} - + + + + {__('Share')} + + this.setState({ showTipView: true })} + > + + {__('Tip')} + + + {!canEdit && !isPlayable && ( + + {!fileInfo || + (fileInfo.written_bytes <= 0 && !completed && ( + + + {__('Download')} + + ))} + + {!completed && + fileInfo && + !fileInfo.stopped && + fileInfo.written_bytes > 0 && + fileInfo.written_bytes < fileInfo.total_bytes && + !this.state.stopDownloadConfirmed && ( + + + {__('Stop')} + + )} + + {completed && fileInfo && fileInfo.written_bytes >= fileInfo.total_bytes && ( + + + {__('Open')} + + )} + + )} + + {!canEdit && ( this.setState({ showTipView: true })} + onPress={() => Linking.openURL(`https://lbry.com/dmca/${claim.claim_id}`)} > - - {__('Tip')} + + {__('Report')} + )} - {!canEdit && !isPlayable && ( - - {!fileInfo || - (fileInfo.written_bytes <= 0 && !completed && ( - - - {__('Download')} - - ))} + {canEdit && ( + + + {__('Edit')} + + )} - {!completed && - fileInfo && - !fileInfo.stopped && - fileInfo.written_bytes > 0 && - fileInfo.written_bytes < fileInfo.total_bytes && - !this.state.stopDownloadConfirmed && ( - - - {__('Stop')} - - )} + {(completed || canEdit) && ( + + + {__('Delete')} + + )} + - {completed && fileInfo && fileInfo.written_bytes >= fileInfo.total_bytes && ( - - - {__('Open')} - - )} + + + {channelName && ( + { + navigateToUri( + navigation, + normalizeURI(shortChannelUri || fullChannelUri), + null, + false, + fullChannelUri + ); + }} + /> + )} + {!channelName && ( + + {__('Anonymous')} + + )} + + + + {false && ((isPlayable && !fileInfo) || (isPlayable && fileInfo && !fileInfo.download_path)) && ( +