Compare commits

...
Author SHA1 Message Date
Akinwale Ariwodola 15cbdcfaca add reactotron. fix batch resolve functionality for search results. 2019-12-29 10:34:00 +01:00
Akinwale Ariwodola 30246a189c remove console.log 2019-12-29 07:23:42 +01:00
Akinwale Ariwodola f77f0a7aa2 search tweaks and package updates 2019-12-29 06:48:13 +01:00
Akinwale Ariwodola 36d4bd7e99 Merge pull request #104 from lbryio/navigation-drawer-test
update react-navigation-drawer package
2019-12-29 06:45:47 +01:00
Akinwale Ariwodola b8f2a9e24f tweak related content view for perf. fix displayed dates. 2019-12-28 21:02:29 +01:00
Akinwale Ariwodola d7edbf55b5 react-navigation-drawer 2.3.3 2019-12-28 19:36:17 +01:00
Akinwale Ariwodola d362d9e8dd remove console.log 2019-12-28 15:56:37 +01:00
Akinwale Ariwodola f47693fb35 First run changes (#103)
* streamlined first run
* download button tweaks
* fix downloads. file page tweaks.
2019-12-28 15:45:12 +01:00
Akinwale Ariwodola 54b10c818e Merge pull request #102 from lbryio/react-native-0.61
update to RN 0.61.5
2019-12-28 15:16:56 +01:00
Akinwale Ariwodola 4b283e6606 update to RN 0.61.5 2019-12-28 15:14:37 +01:00
18 changed files with 3951 additions and 2274 deletions

No files matched your search

+4
View File
@@ -1,3 +1,7 @@
if (__DEV__) {
import('./reactotron').then(() => console.log('Reactotron Configured'));
}
import LBRYApp from './src/index'; import LBRYApp from './src/index';
export default LBRYApp; export default LBRYApp;
+3399 -1850
View File
File diff suppressed because it is too large. Load diff
+22 -19
View File
@@ -12,50 +12,50 @@
"base-64": "^0.1.0", "base-64": "^0.1.0",
"@expo/vector-icons": "^8.1.0", "@expo/vector-icons": "^8.1.0",
"gfycat-style-urls": "^1.0.3", "gfycat-style-urls": "^1.0.3",
"lbry-redux": "lbryio/lbry-redux#abe90e0665cfad3fb8853501ec058c5d1f0d9cc8", "lbry-redux": "lbryio/lbry-redux#2c569a729bb40d45249ca38150b00922162b7ce3",
"lbryinc": "lbryio/lbryinc#053ca52f4f7f9bf8eb62a3581b183671a475ad1c", "lbryinc": "lbryio/lbryinc#053ca52f4f7f9bf8eb62a3581b183671a475ad1c",
"lodash": ">=4.17.11", "lodash": ">=4.17.11",
"merge": ">=1.2.1", "merge": ">=1.2.1",
"moment": "^2.22.1", "moment": "^2.22.1",
"react": "16.8.6", "react": "16.9.0",
"react-native": "0.59.10", "react-native": "0.61.5",
"@react-native-community/async-storage": "^1.5.1", "@react-native-community/async-storage": "^1.5.1",
"react-native-camera": "^2.11.1", "react-native-camera": "^3.15.0",
"react-native-country-picker-modal": "^0.6.2", "react-native-country-picker-modal": "^1.10.0",
"react-native-exception-handler": "2.9.0", "react-native-exception-handler": "2.9.0",
"react-native-fast-image": "^6.1.1", "react-native-fast-image": "^7.0.2",
"react-native-fs": "^2.13.3", "react-native-fs": "^2.13.3",
"react-native-gesture-handler": "1.3.0", "react-native-gesture-handler": "1.5.2",
"react-native-image-zoom-viewer": "^2.2.5", "react-native-image-zoom-viewer": "^2.2.5",
"react-native-password-strength-meter": "^0.0.2", "react-native-password-strength-meter": "^0.0.2",
"react-native-phone-input": "lbryio/react-native-phone-input", "react-native-phone-input": "lbryio/react-native-phone-input",
"react-native-reanimated": "1.2.0", "react-native-reanimated": "1.4.0",
"react-native-snackbar": "1.0.2", "react-native-snackbar": "2.0.4",
"react-native-super-grid": "^3.0.4", "react-native-super-grid": "^3.0.4",
"react-native-vector-icons": "^6.6.0", "react-native-vector-icons": "^6.6.0",
"react-native-video": "lbryio/react-native-video#exoplayer-lbry-android", "react-native-video": "lbryio/react-native-video#7992ff945872f9bd00a3736d9ff1318f343abf47",
"react-navigation": "^3.11.0", "react-navigation": "^3.13.0",
"react-navigation-drawer": "^1.4.0", "react-navigation-drawer": "^2.3.3",
"react-navigation-redux-helpers": "^3.0.2", "react-navigation-redux-helpers": "^3.0.2",
"react-navigation-stack": "^1.8.1", "react-navigation-stack": "^1.8.1",
"react-redux": "^5.0.3", "react-redux": "^5.0.3",
"redux": "^4.0.4", "redux": "^4.0.4",
"redux-persist": "^5.10.0", "redux-persist": "^6.0.0",
"redux-persist-filesystem-storage": "^1.3.2", "redux-persist-filesystem-storage": "^2.1.0",
"redux-persist-transform-compress": "^4.2.0", "redux-persist-transform-compress": "^4.2.0",
"redux-persist-transform-filter": "0.0.18", "redux-persist-transform-filter": "0.0.18",
"redux-thunk": "^2.3.0", "redux-thunk": "^2.3.0",
"rn-fetch-blob": "0.10.15", "rn-fetch-blob": "0.12.0",
"seedrandom": "3.0.3" "seedrandom": "3.0.3"
}, },
"devDependencies": { "devDependencies": {
"@babel/core": "^7.5.4", "@babel/core": "^7.6.2",
"babel-eslint": "10.0.2", "babel-eslint": "10.0.2",
"@babel/plugin-proposal-object-rest-spread": "^7.5.4", "@babel/plugin-proposal-object-rest-spread": "^7.5.4",
"babel-preset-env": "^1.6.1", "babel-preset-env": "^1.6.1",
"babel-preset-stage-2": "^6.18.0", "babel-preset-stage-2": "^6.18.0",
"babel-plugin-module-resolver": "^3.1.1", "babel-plugin-module-resolver": "^3.1.1",
"eslint": "^5.16.0", "eslint": "^6.5.1",
"eslint-config-standard": "^12.0.0", "eslint-config-standard": "^12.0.0",
"eslint-config-standard-jsx": "^6.0.2", "eslint-config-standard-jsx": "^6.0.2",
"eslint-plugin-flowtype": "^2.46.1", "eslint-plugin-flowtype": "^2.46.1",
@@ -67,8 +67,11 @@
"flow-babel-webpack-plugin": "^1.1.1", "flow-babel-webpack-plugin": "^1.1.1",
"husky": "^0.14.3", "husky": "^0.14.3",
"lint-staged": "^7.0.4", "lint-staged": "^7.0.4",
"metro-react-native-babel-preset": "^0.55.0", "metro-react-native-babel-preset": "^0.56.0",
"prettier": "^1.11.1", "prettier": "^1.11.1",
"react-devtools": "^3.6.3" "@react-native-community/eslint-config": "^0.0.5",
"react-devtools": "^3.6.3",
"reactotron-react-native": "4.0.2",
"reactotron-redux": "3.1.2"
} }
} }
+8
View File
@@ -0,0 +1,8 @@
import AsyncStorage from '@react-native-community/async-storage';
import Reactotron from 'reactotron-react-native'
Reactotron
.setAsyncStorageHandler(AsyncStorage) // AsyncStorage would either come from `react-native` or `@react-native-community/async-storage` depending on where you get it from
.configure() // controls connection & communication settings
.useReactNative() // add all built-in react native plugins
.connect(); // let's connect!
+27
View File
@@ -51,6 +51,7 @@ import {
selectHashChanged, selectHashChanged,
selectUser, selectUser,
} from 'lbryinc'; } from 'lbryinc';
import { doStartDownload, doUpdateDownload, doCompleteDownload } from 'redux/actions/file';
import { makeSelectClientSetting, selectFullscreenMode } from 'redux/selectors/settings'; import { makeSelectClientSetting, selectFullscreenMode } from 'redux/selectors/settings';
import { decode as atob } from 'base-64'; import { decode as atob } from 'base-64';
import { dispatchNavigateBack, dispatchNavigateToUri, transformUrl } from 'utils/helper'; import { dispatchNavigateBack, dispatchNavigateToUri, transformUrl } from 'utils/helper';
@@ -311,6 +312,10 @@ class AppWithNavigationState extends React.Component {
this.emailVerifyCheckInterval = setInterval(() => this.checkEmailVerification(), 5000); this.emailVerifyCheckInterval = setInterval(() => this.checkEmailVerification(), 5000);
Linking.addEventListener('url', this._handleUrl); Linking.addEventListener('url', this._handleUrl);
DeviceEventEmitter.addListener('onDownloadStarted', this.handleDownloadStarted);
DeviceEventEmitter.addListener('onDownloadUpdated', this.handleDownloadUpdated);
DeviceEventEmitter.addListener('onDownloadCompleted', this.handleDownloadCompleted);
// call /sync/get with interval // call /sync/get with interval
this.syncGetInterval = setInterval(() => { this.syncGetInterval = setInterval(() => {
this.setState({ syncHashChanged: false }); // reset local state this.setState({ syncHashChanged: false }); // reset local state
@@ -345,7 +350,29 @@ class AppWithNavigationState extends React.Component {
); );
}; };
handleDownloadStarted = evt => {
const { dispatch } = this.props;
const { uri, outpoint, fileInfo } = evt;
dispatch(doStartDownload(uri, outpoint, fileInfo));
};
handleDownloadUpdated = evt => {
const { dispatch } = this.props;
const { uri, outpoint, fileInfo, progress } = evt;
dispatch(doUpdateDownload(uri, outpoint, fileInfo, progress));
};
handleDownloadCompleted = evt => {
const { dispatch } = this.props;
const { uri, outpoint, fileInfo } = evt;
dispatch(doCompleteDownload(uri, outpoint, fileInfo));
};
componentWillUnmount() { componentWillUnmount() {
DeviceEventEmitter.removeListener('onDownloadStarted', this.handleDownloadStarted);
DeviceEventEmitter.removeListener('onDownloadUpdated', this.handleDownloadUpdated);
DeviceEventEmitter.removeListener('onDownloadCompleted', this.handleDownloadCompleted);
AppState.removeEventListener('change', this._handleAppStateChange); AppState.removeEventListener('change', this._handleAppStateChange);
BackHandler.removeEventListener('hardwareBackPress'); BackHandler.removeEventListener('hardwareBackPress');
Linking.removeEventListener('url', this._handleUrl); Linking.removeEventListener('url', this._handleUrl);
+2 -18
View File
@@ -11,11 +11,6 @@ class FileDownloadButton extends React.PureComponent {
} }
} }
componentWillReceiveProps(nextProps) {
// this.checkAvailability(nextProps.uri);
// this.restartDownload(nextProps);
}
restartDownload(props) { restartDownload(props) {
const { downloading, fileInfo, uri, restartDownload } = props; const { downloading, fileInfo, uri, restartDownload } = props;
@@ -45,6 +40,7 @@ class FileDownloadButton extends React.PureComponent {
doPause, doPause,
style, style,
openFile, openFile,
onFileActionPress,
onButtonLayout, onButtonLayout,
} = this.props; } = this.props;
@@ -72,19 +68,7 @@ class FileDownloadButton extends React.PureComponent {
text={isPlayable ? __('Play') : isViewable ? __('View') : __('Download')} text={isPlayable ? __('Play') : isViewable ? __('View') : __('Download')}
onLayout={onButtonLayout} onLayout={onButtonLayout}
style={[style, fileDownloadButtonStyle.container]} style={[style, fileDownloadButtonStyle.container]}
onPress={() => { onPress={onFileActionPress}
NativeModules.Firebase.track('purchase_uri', { uri: uri });
purchaseUri(uri, costInfo, !isPlayable);
if (NativeModules.UtilityModule) {
NativeModules.UtilityModule.checkDownloads();
}
if (isPlayable && onPlay) {
this.props.onPlay();
}
if (isViewable && onView) {
this.props.onView();
}
}}
/> />
); );
} else if (fileInfo && fileInfo.download_path) { } else if (fileInfo && fileInfo.download_path) {
+13 -5
View File
@@ -42,13 +42,15 @@ class FileListItem extends React.PureComponent {
componentDidMount() { componentDidMount() {
const { claim, resolveUri, uri, batchResolve } = this.props; const { claim, resolveUri, uri, batchResolve } = this.props;
if (!claim && !batchResolve) { if (!claim && !batchResolve) {
console.log('resolving on componentDidMount?');
resolveUri(uri); resolveUri(uri);
} }
} }
componentDidUpdate() { componentDidUpdate() {
const { claim, resolveUri, uri } = this.props; const { claim, resolveUri, uri, batchResolve } = this.props;
if (!claim && uri !== this.state.url) { if (!claim && uri !== this.state.url && !batchResolve) {
console.log('resolving on componentDidUpdate?');
this.setState({ url: uri }, () => resolveUri(uri)); this.setState({ url: uri }, () => resolveUri(uri));
} }
} }
@@ -158,7 +160,13 @@ class FileListItem extends React.PureComponent {
</View> </View>
)} )}
{fileInfo && fileInfo.completed && fileInfo.download_path && ( {fileInfo && fileInfo.completed && fileInfo.download_path && (
<Icon style={fileListStyle.downloadedIcon} solid color={Colors.NextLbryGreen} name={'folder'} size={16} /> <Icon
style={featuredResult ? fileListStyle.featuredDownloadedIcon : fileListStyle.downloadedIcon}
solid
color={Colors.NextLbryGreen}
name={'folder'}
size={16}
/>
)} )}
<View style={fileListStyle.detailsContainer}> <View style={fileListStyle.detailsContainer}>
{featuredResult && ( {featuredResult && (
@@ -172,7 +180,7 @@ class FileListItem extends React.PureComponent {
{!title && !name && <Text style={fileListStyle.uri}>{uri}</Text>} {!title && !name && <Text style={fileListStyle.uri}>{uri}</Text>}
{!title && !name && ( {!title && !name && (
<View style={fileListStyle.row}> <View style={fileListStyle.row}>
<ActivityIndicator size={'small'} color={featuredResult ? Colors.White : Colors.LbryGreen} /> <ActivityIndicator size={'small'} color={featuredResult ? Colors.White : Colors.NextLbryGreen} />
</View> </View>
)} )}
</View> </View>
@@ -203,7 +211,7 @@ class FileListItem extends React.PureComponent {
normalizeURI(shortChannelUri || fullChannelUri), normalizeURI(shortChannelUri || fullChannelUri),
null, null,
false, false,
fullChannelUri fullChannelUri,
); );
}} }}
/> />
+6 -4
View File
@@ -1,25 +1,27 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { import {
doResolveUris, doResolveUris,
doSearch,
makeSelectClaimForUri, makeSelectClaimForUri,
makeSelectRecommendedContentForUri, makeSelectRecommendedContentForUri,
makeSelectTitleForUri, selectResolvingUris,
selectIsSearching, selectIsSearching,
} from 'lbry-redux'; } from 'lbry-redux';
import RelatedContent from './view'; import RelatedContent from './view';
const select = (state, props) => ({ const select = (state, props) => ({
claim: makeSelectClaimForUri(props.uri)(state), claim: makeSelectClaimForUri(props.uri)(state),
recommendedContent: makeSelectRecommendedContentForUri(props.uri)(state),
title: makeSelectTitleForUri(props.uri)(state),
isSearching: selectIsSearching(state), isSearching: selectIsSearching(state),
recommendedContent: makeSelectRecommendedContentForUri(props.uri)(state),
resolvingUris: selectResolvingUris(state),
}); });
const perform = dispatch => ({ const perform = dispatch => ({
resolveUris: uris => dispatch(doResolveUris(uris)), resolveUris: uris => dispatch(doResolveUris(uris)),
searchRecommended: query => dispatch(doSearch(query, 20, undefined, true, false)),
}); });
export default connect( export default connect(
select, select,
perform perform,
)(RelatedContent); )(RelatedContent);
+35 -8
View File
@@ -9,26 +9,53 @@ import relatedContentStyle from 'styles/relatedContent';
export default class RelatedContent extends React.PureComponent { export default class RelatedContent extends React.PureComponent {
state = { state = {
urlsResolved: false, resolveStarted: false,
}; };
componentDidUpdate(prevProps) { componentDidMount() {
const { resolveUris, recommendedContent } = this.props; const { title, searchRecommended } = this.props;
if (title) {
searchRecommended(title);
}
}
if (recommendedContent && recommendedContent.length > 0 && !this.state.urisResolved) { shouldComponentUpdate(nextProps, nextState) {
this.setState({ urisResolved: true }, () => { const { isSearching, recommendedContent } = nextProps;
// batch resolve the uris return isSearching || (!isSearching && this.allContentResolved());
resolveUris(recommendedContent); }
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 { isSearching, resolveUris, recommendedContent } = this.props;
if (!isSearching && !this.state.resolveStarted) {
this.setState({ resolveStarted: true }, () => {
if (recommendedContent && recommendedContent.length > 0) {
// batch resolve the uris
resolveUris(recommendedContent);
}
}); });
} }
} }
render() { render() {
const { recommendedContent, navigation, uri, fullUri } = this.props; const { isSearching, recommendedContent, navigation, uri, fullUri } = this.props;
return ( return (
<View style={relatedContentStyle.container}> <View style={relatedContentStyle.container}>
<Text style={relatedContentStyle.title}>{__('Related Content')}</Text> <Text style={relatedContentStyle.title}>{__('Related Content')}</Text>
{isSearching && <ActivityIndicator size={'small'} color={Colors.NextLbryGreen} />}
{recommendedContent && {recommendedContent &&
recommendedContent recommendedContent
.filter(recommendedUri => recommendedUri !== normalizeURI(fullUri)) .filter(recommendedUri => recommendedUri !== normalizeURI(fullUri))
+3 -2
View File
@@ -52,8 +52,9 @@ function checkMessageAndSave(message, messagesFilePath) {
); */ ); */
}) })
.catch(err => { .catch(err => {
if (err) { if (err && !isProduction) {
throw err; // only do this when not in production
console.error(err);
} }
}); });
} }
+1 -1
View File
@@ -57,7 +57,7 @@ window.__ = __;
const globalExceptionHandler = (error, isFatal) => { const globalExceptionHandler = (error, isFatal) => {
if (error && NativeModules.Firebase) { if (error && NativeModules.Firebase) {
NativeModules.Firebase.logException(isFatal, error.message ? error.message : 'No message', JSON.stringify(error)); NativeModules.Firebase.logException(!!isFatal, error.message ? error.message : 'No message', JSON.stringify(error));
} }
}; };
setJSExceptionHandler(globalExceptionHandler, true); setJSExceptionHandler(globalExceptionHandler, true);
+4 -15
View File
@@ -8,7 +8,7 @@ import {
doPurchaseUri, doPurchaseUri,
doDeletePurchasedUri, doDeletePurchasedUri,
doResolveUri, doResolveUri,
doSearch, doResolveUris,
doSendTip, doSendTip,
doToast, doToast,
makeSelectIsUriResolving, makeSelectIsUriResolving,
@@ -18,7 +18,6 @@ import {
makeSelectContentPositionForUri, makeSelectContentPositionForUri,
makeSelectContentTypeForUri, makeSelectContentTypeForUri,
makeSelectMetadataForUri, makeSelectMetadataForUri,
makeSelectRecommendedContentForUri,
makeSelectStreamingUrlForUri, makeSelectStreamingUrlForUri,
makeSelectThumbnailForUri, makeSelectThumbnailForUri,
makeSelectTitleForUri, makeSelectTitleForUri,
@@ -39,13 +38,7 @@ import {
selectRewardContentClaimIds, selectRewardContentClaimIds,
selectBlackListedOutpoints, selectBlackListedOutpoints,
} from 'lbryinc'; } from 'lbryinc';
import { import { doDeleteFile, doStopDownloadingFile } from 'redux/actions/file';
doStartDownload,
doUpdateDownload,
doCompleteDownload,
doDeleteFile,
doStopDownloadingFile,
} from 'redux/actions/file';
import { doPushDrawerStack, doPopDrawerStack, doSetPlayerVisible } from 'redux/actions/drawer'; import { doPushDrawerStack, doPopDrawerStack, doSetPlayerVisible } from 'redux/actions/drawer';
import { doToggleFullscreenMode } from 'redux/actions/settings'; import { doToggleFullscreenMode } from 'redux/actions/settings';
import { selectDrawerStack } from 'redux/selectors/drawer'; import { selectDrawerStack } from 'redux/selectors/drawer';
@@ -76,7 +69,6 @@ const select = (state, props) => {
streamingUrl: makeSelectStreamingUrlForUri(contentUri)(state), streamingUrl: makeSelectStreamingUrlForUri(contentUri)(state),
thumbnail: makeSelectThumbnailForUri(contentUri)(state), thumbnail: makeSelectThumbnailForUri(contentUri)(state),
title: makeSelectTitleForUri(contentUri)(state), title: makeSelectTitleForUri(contentUri)(state),
recommendedContent: makeSelectRecommendedContentForUri(contentUri)(state),
isSearchingRecommendContent: selectIsSearching(state), isSearchingRecommendContent: selectIsSearching(state),
viewCount: makeSelectViewCountForUri(contentUri)(state), viewCount: makeSelectViewCountForUri(contentUri)(state),
}; };
@@ -100,18 +92,15 @@ const perform = dispatch => ({
purchaseUri: (uri, costInfo, saveFile) => dispatch(doPurchaseUri(uri, costInfo, saveFile)), purchaseUri: (uri, costInfo, saveFile) => dispatch(doPurchaseUri(uri, costInfo, saveFile)),
deletePurchasedUri: uri => dispatch(doDeletePurchasedUri(uri)), deletePurchasedUri: uri => dispatch(doDeletePurchasedUri(uri)),
resolveUri: uri => dispatch(doResolveUri(uri)), resolveUri: uri => dispatch(doResolveUri(uri)),
searchRecommended: query => dispatch(doSearch(query, 20, undefined, true)), resolveUris: uris => dispatch(doResolveUris(uris)),
sendTip: (amount, claimId, isSupport, successCallback, errorCallback) => sendTip: (amount, claimId, isSupport, successCallback, errorCallback) =>
dispatch(doSendTip(amount, claimId, isSupport, successCallback, errorCallback)), dispatch(doSendTip(amount, claimId, isSupport, successCallback, errorCallback)),
setPlayerVisible: () => dispatch(doSetPlayerVisible(true)), setPlayerVisible: () => dispatch(doSetPlayerVisible(true)),
stopDownload: (uri, fileInfo) => dispatch(doStopDownloadingFile(uri, fileInfo)), stopDownload: (uri, fileInfo) => dispatch(doStopDownloadingFile(uri, fileInfo)),
startDownload: (uri, outpoint, fileInfo) => dispatch(doStartDownload(uri, outpoint, fileInfo)),
updateDownload: (uri, outpoint, fileInfo, progress) => dispatch(doUpdateDownload(uri, outpoint, fileInfo, progress)),
completeDownload: (uri, outpoint, fileInfo) => dispatch(doCompleteDownload(uri, outpoint, fileInfo)),
toggleFullscreenMode: mode => dispatch(doToggleFullscreenMode(mode)), toggleFullscreenMode: mode => dispatch(doToggleFullscreenMode(mode)),
}); });
export default connect( export default connect(
select, select,
perform perform,
)(FilePage); )(FilePage);
+341 -321
View File
@@ -72,6 +72,7 @@ class FilePage extends React.PureComponent {
fileViewLogged: false, fileViewLogged: false,
fullscreenMode: false, fullscreenMode: false,
fileGetStarted: false, fileGetStarted: false,
hasCheckedAllResolved: false,
imageUrls: null, imageUrls: null,
isLandscape: false, isLandscape: false,
mediaLoaded: false, mediaLoaded: false,
@@ -86,6 +87,7 @@ class FilePage extends React.PureComponent {
playerHeight: 0, playerHeight: 0,
uri: null, uri: null,
uriVars: null, uriVars: null,
showRecommended: false,
stopDownloadConfirmed: false, stopDownloadConfirmed: false,
streamingMode: false, streamingMode: false,
viewCountFetched: false, viewCountFetched: false,
@@ -101,29 +103,24 @@ class FilePage extends React.PureComponent {
onComponentFocused = () => { onComponentFocused = () => {
StatusBar.setHidden(false); StatusBar.setHidden(false);
NativeModules.Firebase.setCurrentScreen('File'); NativeModules.Firebase.setCurrentScreen('File').then(result => {
DeviceEventEmitter.addListener('onStoragePermissionGranted', this.handleStoragePermissionGranted);
DeviceEventEmitter.addListener('onStoragePermissionRefused', this.handleStoragePermissionRefused);
DeviceEventEmitter.addListener('onDownloadStarted', this.handleDownloadStarted); const { claim, fetchMyClaims, fileInfo, isResolvingUri, resolveUri, navigation } = this.props;
DeviceEventEmitter.addListener('onDownloadUpdated', this.handleDownloadUpdated); const { uri, uriVars } = navigation.state.params;
DeviceEventEmitter.addListener('onDownloadCompleted', this.handleDownloadCompleted); this.setState({ uri, uriVars });
const { fetchMyClaims, fileInfo, isResolvingUri, resolveUri, navigation } = this.props; if (!isResolvingUri && !claim) resolveUri(uri);
const { uri, uriVars } = navigation.state.params;
this.setState({ uri, uriVars });
if (!isResolvingUri) resolveUri(uri); this.fetchFileInfo(this.props);
this.fetchCostInfo(this.props);
this.fetchFileInfo(this.props); fetchMyClaims();
this.fetchCostInfo(this.props);
fetchMyClaims();
if (NativeModules.Firebase) {
NativeModules.Firebase.track('open_file_page', { uri: uri }); NativeModules.Firebase.track('open_file_page', { uri: uri });
}
if (NativeModules.UtilityModule) {
NativeModules.UtilityModule.keepAwakeOn(); NativeModules.UtilityModule.keepAwakeOn();
} });
}; };
componentDidMount() { componentDidMount() {
@@ -151,6 +148,7 @@ class FilePage extends React.PureComponent {
navigation, navigation,
contentType, contentType,
notify, notify,
recommendedContent: prevRecommendedContent,
drawerStack: prevDrawerStack, drawerStack: prevDrawerStack,
} = this.props; } = this.props;
const { uri } = navigation.state.params; const { uri } = navigation.state.params;
@@ -162,6 +160,8 @@ class FilePage extends React.PureComponent {
purchaseUriErrorMessage, purchaseUriErrorMessage,
streamingUrl, streamingUrl,
drawerStack, drawerStack,
recommendedContent,
resolveUris,
} = nextProps; } = nextProps;
if (Constants.ROUTE_FILE === currentRoute && currentRoute !== prevRoute) { if (Constants.ROUTE_FILE === currentRoute && currentRoute !== prevRoute) {
@@ -177,11 +177,9 @@ class FilePage extends React.PureComponent {
const mediaType = Lbry.getMediaType(contentType); const mediaType = Lbry.getMediaType(contentType);
const isPlayable = mediaType === 'video' || mediaType === 'audio'; const isPlayable = mediaType === 'video' || mediaType === 'audio';
if ( if (this.state.fileGetStarted || prevPurchasedUris.length !== purchasedUris.length) {
(this.state.fileGetStarted || prevPurchasedUris.length !== purchasedUris.length) && const { permanent_url: permanentUrl } = claim;
NativeModules.UtilityModule if (purchasedUris.includes(uri) || purchasedUris.includes(permanentUrl)) {
) {
if (purchasedUris.includes(uri)) {
const { nout, txid } = claim; const { nout, txid } = claim;
const outpoint = `${txid}:${nout}`; const outpoint = `${txid}:${nout}`;
NativeModules.UtilityModule.queueDownload(outpoint); NativeModules.UtilityModule.queueDownload(outpoint);
@@ -216,9 +214,23 @@ class FilePage extends React.PureComponent {
if (claim && !this.state.viewCountFetched) { if (claim && !this.state.viewCountFetched) {
this.setState({ viewCountFetched: true }, () => fetchViewCount(claim.claim_id)); this.setState({ viewCountFetched: true }, () => fetchViewCount(claim.claim_id));
} }
if (
(!prevRecommendedContent && recommendedContent) ||
(recommendedContent && prevRecommendedContent && recommendedContent.length !== prevRecommendedContent.length)
) {
resolveUris(recommendedContent);
}
} }
componentDidUpdate(prevProps) { shouldComponentUpdate(nextProps, nextState) {
return (
Object.keys(this.difference(nextProps, this.props)).length > 0 ||
Object.keys(this.difference(nextState, this.state)).length > 0
);
}
componentDidUpdate(prevProps, prevState) {
const { const {
claim, claim,
contentType, contentType,
@@ -228,7 +240,6 @@ class FilePage extends React.PureComponent {
resolveUri, resolveUri,
navigation, navigation,
purchaseUri, purchaseUri,
searchRecommended,
title, title,
} = this.props; } = this.props;
const { uri } = this.state; const { uri } = this.state;
@@ -236,10 +247,6 @@ class FilePage extends React.PureComponent {
resolveUri(uri); resolveUri(uri);
} }
if (title && !this.state.didSearchRecommended) {
this.setState({ didSearchRecommended: true }, () => searchRecommended(title));
}
// Returned to the page. If mediaLoaded, and currentMediaInfo is different, update // Returned to the page. If mediaLoaded, and currentMediaInfo is different, update
if (this.state.mediaLoaded && window.currentMediaInfo && window.currentMediaInfo.uri !== this.state.uri) { if (this.state.mediaLoaded && window.currentMediaInfo && window.currentMediaInfo.uri !== this.state.uri) {
const { metadata } = this.props; const { metadata } = this.props;
@@ -254,15 +261,7 @@ class FilePage extends React.PureComponent {
const mediaType = Lbry.getMediaType(contentType); const mediaType = Lbry.getMediaType(contentType);
const isViewable = mediaType === 'image' || mediaType === 'text'; const isViewable = mediaType === 'image' || mediaType === 'text';
if (claim && costInfo && costInfo.cost === 0 && !this.state.autoGetAttempted && isViewable) { if (claim && costInfo && costInfo.cost === 0 && !this.state.autoGetAttempted && isViewable) {
this.setState( this.setState({ autoGetAttempted: true }, () => this.checkStoragePermissionForDownload());
{
autoGetAttempted: true,
downloadPressed: true,
autoPlayMedia: true,
stopDownloadConfirmed: false,
},
() => purchaseUri(claim.permanent_url, costInfo, true)
);
} }
} }
@@ -341,7 +340,7 @@ class FilePage extends React.PureComponent {
}, },
}, },
], ],
{ cancelable: true } { cancelable: true },
); );
}; };
@@ -377,7 +376,7 @@ class FilePage extends React.PureComponent {
}, },
}, },
], ],
{ cancelable: true } { cancelable: true },
); );
}; };
@@ -399,27 +398,34 @@ class FilePage extends React.PureComponent {
} }
window.player = null; window.player = null;
DeviceEventEmitter.removeListener('onDownloadStarted', this.handleDownloadStarted); DeviceEventEmitter.removeListener('onStoragePermissionGranted', this.handleStoragePermissionGranted);
DeviceEventEmitter.removeListener('onDownloadUpdated', this.handleDownloadUpdated); DeviceEventEmitter.removeListener('onStoragePermissionRefused', this.handleStoragePermissionRefused);
DeviceEventEmitter.removeListener('onDownloadCompleted', this.handleDownloadCompleted);
} }
handleDownloadStarted = evt => { handleStoragePermissionGranted = () => {
const { startDownload } = this.props; // permission was allowed. proceed to download
const { uri, outpoint, fileInfo } = evt; const { notify } = this.props;
startDownload(uri, outpoint, fileInfo);
// update the configured download folder and then download
NativeModules.UtilityModule.getDownloadDirectory().then(downloadDirectory => {
Lbry.settings_set({
key: 'download_dir',
value: downloadDirectory,
})
.then(() => this.performDownload())
.catch(() => {
notify({ message: 'The file could not be downloaded to the default download directory.', isError: true });
});
});
}; };
handleDownloadUpdated = evt => { handleStoragePermissionRefused = () => {
const { updateDownload } = this.props; const { notify } = this.props;
const { uri, outpoint, fileInfo, progress } = evt; this.setState({ downloadPressed: false });
updateDownload(uri, outpoint, fileInfo, progress); notify({
}; message: __('The file could not be downloaded because the permission to write to storage was not granted.'),
isError: true,
handleDownloadCompleted = evt => { });
const { completeDownload } = this.props;
const { uri, outpoint, fileInfo } = evt;
completeDownload(uri, outpoint, fileInfo);
}; };
localUriForFileInfo = fileInfo => { localUriForFileInfo = fileInfo => {
@@ -536,6 +542,9 @@ class FilePage extends React.PureComponent {
payload['time_to_start_ms'] = timeToStartMillis; payload['time_to_start_ms'] = timeToStartMillis;
} }
NativeModules.Firebase.track('play', payload); NativeModules.Firebase.track('play', payload);
// only fetch recommended content after playback has started
this.setState({ showRecommended: true });
}; };
onPlaybackFinished = () => { onPlaybackFinished = () => {
@@ -589,14 +598,48 @@ class FilePage extends React.PureComponent {
)); ));
}; };
onFileDownloadButtonPlayed = () => { onFileDownloadButtonPressed = () => {
const { setPlayerVisible } = this.props; const { claim, costInfo, contentType, purchaseUri, setPlayerVisible } = this.props;
this.startTime = Date.now(); const mediaType = Lbry.getMediaType(contentType);
this.setState({ downloadPressed: true, autoPlayMedia: true, stopDownloadConfirmed: false }); const isPlayable = mediaType === 'video' || mediaType === 'audio';
setPlayerVisible(); const isViewable = mediaType === 'image' || mediaType === 'text';
const { permanent_url: uri } = claim;
NativeModules.Firebase.track('purchase_uri', { uri: uri });
if (!isPlayable) {
this.checkStoragePermissionForDownload();
} else {
purchaseUri(uri, costInfo, !isPlayable);
}
if (isPlayable) {
this.startTime = Date.now();
this.setState({ downloadPressed: true, autoPlayMedia: true, stopDownloadConfirmed: false });
setPlayerVisible();
}
if (isViewable) {
this.setState({ downloadPressed: true });
}
}; };
onDownloadPressed = () => { onDownloadPressed = () => {
this.checkStoragePermissionForDownload();
};
checkStoragePermissionForDownload = () => {
// check if we the permission to write to external storage has been granted
NativeModules.UtilityModule.canReadWriteStorage().then(canReadWrite => {
if (!canReadWrite) {
// request permission
NativeModules.UtilityModule.requestStoragePermission();
} else {
this.performDownload();
}
});
};
performDownload = () => {
const { claim, costInfo, purchaseUri } = this.props; const { claim, costInfo, purchaseUri } = this.props;
this.setState( this.setState(
{ {
@@ -604,7 +647,10 @@ class FilePage extends React.PureComponent {
autoPlayMedia: false, autoPlayMedia: false,
stopDownloadConfirmed: false, stopDownloadConfirmed: false,
}, },
() => purchaseUri(claim.permanent_url, costInfo, true) () => {
purchaseUri(claim.permanent_url, costInfo, true);
NativeModules.UtilityModule.checkDownloads();
},
); );
}; };
@@ -621,14 +667,7 @@ class FilePage extends React.PureComponent {
// file already in library or URI already purchased, use fileGet directly // file already in library or URI already purchased, use fileGet directly
this.setState({ fileGetStarted: true }, () => fileGet(uri, true)); this.setState({ fileGetStarted: true }, () => fileGet(uri, true));
} else { } else {
this.setState( this.checkStoragePermissionForDownload();
{
downloadPressed: true,
autoPlayMedia: false,
stopDownloadConfirmed: false,
},
() => purchaseUri(uri, costInfo, true)
);
} }
}; };
@@ -648,7 +687,7 @@ class FilePage extends React.PureComponent {
], ],
showImageViewer: true, showImageViewer: true,
}, },
() => pushDrawerStack(Constants.DRAWER_ROUTE_FILE_VIEW) () => pushDrawerStack(Constants.DRAWER_ROUTE_FILE_VIEW),
); );
} }
} }
@@ -659,23 +698,12 @@ class FilePage extends React.PureComponent {
{ {
showWebView: true, showWebView: true,
}, },
() => pushDrawerStack(Constants.DRAWER_ROUTE_FILE_VIEW) () => pushDrawerStack(Constants.DRAWER_ROUTE_FILE_VIEW),
); );
} }
} }
}; };
onMediaContainerPressed = () => {
const { costInfo, contentType, purchaseUri } = this.props;
const { uri } = this.state;
const mediaType = Lbry.getMediaType(contentType);
const isPlayable = mediaType === 'video' || mediaType === 'audio';
purchaseUri(uri, costInfo, isPlayable);
if (isPlayable) {
this.onFileDownloadButtonPlayed();
}
};
render() { render() {
const { const {
balance, balance,
@@ -710,7 +738,7 @@ class FilePage extends React.PureComponent {
let innerContent = null; let innerContent = null;
if ((isResolvingUri && !claim) || !claim) { if ((isResolvingUri && !claim) || !claim) {
return ( return (
<View style={filePageStyle.container}> <View style={filePageStyle.pageContainer}>
<UriBar value={uri} navigation={navigation} /> <UriBar value={uri} navigation={navigation} />
{isResolvingUri && ( {isResolvingUri && (
<View style={filePageStyle.busyContainer}> <View style={filePageStyle.busyContainer}>
@@ -748,232 +776,229 @@ class FilePage extends React.PureComponent {
); );
} }
if (claim) { let isClaimBlackListed = false;
if (isChannel) { if (blackListedOutpoints) {
return <ChannelPage uri={uri} navigation={navigation} />; for (let i = 0; i < blackListedOutpoints.length; i += 1) {
} const outpoint = blackListedOutpoints[i];
if (outpoint.txid === claim.txid && outpoint.nout === claim.nout) {
let isClaimBlackListed = false; isClaimBlackListed = true;
break;
if (blackListedOutpoints) {
for (let i = 0; i < blackListedOutpoints.length; i += 1) {
const outpoint = blackListedOutpoints[i];
if (outpoint.txid === claim.txid && outpoint.nout === claim.nout) {
isClaimBlackListed = true;
break;
}
} }
} }
}
if (isClaimBlackListed) { if (isClaimBlackListed) {
return ( innerContent = (
<View style={filePageStyle.pageContainer}> <View style={filePageStyle.dmcaContainer}>
<View style={filePageStyle.dmcaContainer}> <Text style={filePageStyle.dmcaText}>
<Text style={filePageStyle.dmcaText}> {__(
{__( '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.' )}
)} </Text>
</Text> <Link style={filePageStyle.dmcaLink} href="https://lbry.com/faq/dmca" text={__('Read More')} />
<Link style={filePageStyle.dmcaLink} href="https://lbry.com/faq/dmca" text={__('Read More')} /> </View>
</View> );
<UriBar value={uri} navigation={navigation} /> }
</View>
);
}
let tags = []; let tags = [];
if (claim && claim.value && claim.value.tags) { if (claim && claim.value && claim.value.tags) {
tags = claim.value.tags; tags = claim.value.tags;
} }
const completed = fileInfo && fileInfo.completed; const completed = fileInfo && fileInfo.completed;
const isRewardContent = rewardedContentClaimIds.includes(claim.claim_id); const isRewardContent = rewardedContentClaimIds.includes(claim.claim_id);
const description = metadata.description ? metadata.description : null; const description = metadata.description ? metadata.description : null;
const mediaType = Lbry.getMediaType(contentType); const mediaType = Lbry.getMediaType(contentType);
const isPlayable = mediaType === 'video' || mediaType === 'audio'; const isPlayable = mediaType === 'video' || mediaType === 'audio';
const isWebViewable = mediaType === 'text'; const isWebViewable = mediaType === 'text';
const { height, signing_channel: signingChannel, value } = claim; const { height, signing_channel: signingChannel, value } = claim;
const channelName = signingChannel && signingChannel.name; const channelName = signingChannel && signingChannel.name;
const channelClaimId = claim && claim.signing_channel && claim.signing_channel.claim_id; const channelClaimId = claim && claim.signing_channel && claim.signing_channel.claim_id;
const fullUri = `${claim.name}#${claim.claim_id}`; const fullUri = `${claim.name}#${claim.claim_id}`;
const canEdit = myClaimUris.includes(normalizeURI(fullUri)); const canEdit = myClaimUris.includes(normalizeURI(fullUri));
const showActions = const showActions =
(canEdit || (fileInfo && fileInfo.download_path)) && (canEdit || (fileInfo && fileInfo.download_path)) &&
!this.state.fullscreenMode && !this.state.fullscreenMode &&
!this.state.showImageViewer && !this.state.showImageViewer &&
!this.state.showWebView; !this.state.showWebView;
const showFileActions = const showFileActions =
canEdit || canEdit ||
(fileInfo && (fileInfo &&
fileInfo.download_path && fileInfo.download_path &&
(completed || (fileInfo && !fileInfo.stopped && fileInfo.written_bytes < fileInfo.total_bytes))); (completed || (fileInfo && !fileInfo.stopped && fileInfo.written_bytes < fileInfo.total_bytes)));
const fullChannelUri = const fullChannelUri =
channelClaimId && channelClaimId.trim().length > 0 channelClaimId && channelClaimId.trim().length > 0
? normalizeURI(`${channelName}#${channelClaimId}`) ? normalizeURI(`${channelName}#${channelClaimId}`)
: normalizeURI(channelName); : normalizeURI(channelName);
const shortChannelUri = signingChannel ? signingChannel.short_url : null; const shortChannelUri = signingChannel ? signingChannel.short_url : null;
const playerStyle = [ const playerStyle = [
filePageStyle.player, filePageStyle.player,
this.state.isLandscape this.state.isLandscape
? filePageStyle.containedPlayerLandscape ? filePageStyle.containedPlayerLandscape
: this.state.fullscreenMode : this.state.fullscreenMode
? filePageStyle.fullscreenPlayer ? filePageStyle.fullscreenPlayer
: filePageStyle.containedPlayer, : filePageStyle.containedPlayer,
]; ];
const playerBgStyle = [filePageStyle.playerBackground, filePageStyle.containedPlayerBackground]; const playerBgStyle = [filePageStyle.playerBackground, filePageStyle.containedPlayerBackground];
const fsPlayerBgStyle = [filePageStyle.playerBackground, filePageStyle.fullscreenPlayerBackground]; const fsPlayerBgStyle = [filePageStyle.playerBackground, filePageStyle.fullscreenPlayerBackground];
// at least 2MB (or the full download) before media can be loaded // at least 2MB (or the full download) before media can be loaded
const canLoadMedia = const canLoadMedia =
this.state.streamingMode || this.state.streamingMode ||
(fileInfo && (fileInfo.written_bytes >= 2097152 || fileInfo.written_bytes === fileInfo.total_bytes)); // 2MB = 1024*1024*2 (fileInfo && (fileInfo.written_bytes >= 2097152 || fileInfo.written_bytes === fileInfo.total_bytes)); // 2MB = 1024*1024*2
const duration = claim && claim.value && claim.value.video ? claim.value.video.duration : null; const duration = claim && claim.value && claim.value.video ? claim.value.video.duration : null;
const isViewable = mediaType === 'image' || mediaType === 'text'; const isViewable = mediaType === 'image' || mediaType === 'text';
const canOpen = isViewable && completed; const canOpen = isViewable && completed;
const localFileUri = this.localUriForFileInfo(fileInfo); const localFileUri = this.localUriForFileInfo(fileInfo);
const unsupported = !isPlayable && !canOpen; const unsupported = !isPlayable && !canOpen;
if (fileInfo && !this.state.autoDownloadStarted && this.state.uriVars && this.state.uriVars.download === 'true') { if (
this.setState({ autoDownloadStarted: true }, () => { !this.state.autoDownloadStarted &&
purchaseUri(uri, costInfo, !isPlayable); claim &&
if (NativeModules.UtilityModule) { costInfo &&
NativeModules.UtilityModule.checkDownloads(); ((isPlayable && costInfo.cost === 0) || (this.state.uriVars && this.state.uriVars.download === 'true'))
} ) {
}); this.setState({ autoDownloadStarted: true }, () => {
} if (!isPlayable) {
this.checkStoragePermissionForDownload();
} else {
purchaseUri(claim.permanent_url, costInfo, !isPlayable);
}
NativeModules.UtilityModule.checkDownloads();
});
}
if (this.state.downloadPressed && canOpen && !this.state.autoOpened) { if (this.state.downloadPressed && canOpen && !this.state.autoOpened) {
// automatically open a web viewable or image file after the download button is pressed // automatically open a web viewable or image file after the download button is pressed
this.setState({ autoOpened: true }, () => this.openFile(localFileUri, mediaType)); this.setState({ autoOpened: true }, () => this.openFile(localFileUri, mediaType));
} }
return ( if (isChannel) {
<View style={filePageStyle.pageContainer}> return <ChannelPage uri={uri} navigation={navigation} />;
{!this.state.fullscreenMode && <UriBar value={uri} navigation={navigation} />} }
{this.state.showWebView && isWebViewable && (
<WebView allowFileAccess source={{ uri: localFileUri }} style={filePageStyle.viewer} />
)}
{this.state.showImageViewer && ( return (
<ImageViewer <View style={filePageStyle.pageContainer}>
style={StyleSheet.flatten(filePageStyle.viewer)} {!this.state.fullscreenMode && <UriBar value={uri} navigation={navigation} />}
imageUrls={this.state.imageUrls} {innerContent}
renderIndicator={() => null}
/>
)}
{!this.state.showWebView && ( {this.state.showWebView && isWebViewable && (
<View <WebView allowFileAccess source={{ uri: localFileUri }} style={filePageStyle.viewer} />
style={ )}
this.state.fullscreenMode ? filePageStyle.innerPageContainerFsMode : filePageStyle.innerPageContainer {this.state.showImageViewer && (
} <ImageViewer
onLayout={this.checkOrientation} style={StyleSheet.flatten(filePageStyle.viewer)}
imageUrls={this.state.imageUrls}
renderIndicator={() => null}
/>
)}
{!innerContent && !this.state.showWebView && (
<View
style={
this.state.fullscreenMode ? filePageStyle.innerPageContainerFsMode : filePageStyle.innerPageContainer
}
onLayout={this.checkOrientation}
>
<TouchableOpacity
activeOpacity={0.5}
style={filePageStyle.mediaContainer}
onPress={this.onFileDownloadButtonPressed}
> >
<TouchableOpacity {(canOpen || (!fileInfo || (isPlayable && !canLoadMedia)) || (!canOpen && fileInfo)) && (
activeOpacity={0.5} <FileItemMedia
style={filePageStyle.mediaContainer} duration={duration}
onPress={this.onMediaContainerPressed} style={filePageStyle.thumbnail}
> title={title}
{(canOpen || (!fileInfo || (isPlayable && !canLoadMedia)) || (!canOpen && fileInfo)) && (
<FileItemMedia
duration={duration}
style={filePageStyle.thumbnail}
title={title}
thumbnail={thumbnail}
/>
)}
{!unsupported &&
(!this.state.downloadButtonShown || this.state.downloadPressed) &&
!this.state.mediaLoaded && (
<ActivityIndicator size="large" color={Colors.NextLbryGreen} style={filePageStyle.loading} />
)}
{unsupported && fileInfo && completed && (
<View style={filePageStyle.unsupportedContent}>
<Image
style={filePageStyle.unsupportedContentImage}
resizeMode={'stretch'}
source={require('../../assets/gerbil-happy.png')}
/>
<View style={filePageStyle.unspportedContentTextContainer}>
<Text style={filePageStyle.unsupportedContentTitle}>{__('Unsupported Content')}</Text>
<Text style={filePageStyle.unsupportedContentText}>
Sorry, we are unable to display this content in the app. You can find the file named{' '}
<Text style={filePageStyle.unsupportedContentFilename}>{fileInfo.file_name}</Text> in your
downloads folder.
</Text>
</View>
</View>
)}
{((isPlayable && !completed && !canLoadMedia) ||
canOpen ||
(!completed && !this.state.streamingMode)) &&
!this.state.downloadPressed && (
<FileDownloadButton
uri={claim && claim.permanent_url ? claim.permanent_url : uri}
style={filePageStyle.downloadButton}
openFile={() => this.openFile(localFileUri, mediaType)}
isPlayable={isPlayable}
isViewable={isViewable}
onPlay={this.onFileDownloadButtonPlayed}
onView={() => this.setState({ downloadPressed: true })}
onButtonLayout={() => this.setState({ downloadButtonShown: true })}
/>
)}
{!fileInfo && (
<FilePrice
uri={uri}
style={filePageStyle.filePriceContainer}
textStyle={filePageStyle.filePriceText}
/>
)}
<TouchableOpacity style={filePageStyle.backButton} onPress={this.onBackButtonPressed}>
<Icon name={'arrow-left'} size={18} style={filePageStyle.backButtonIcon} />
</TouchableOpacity>
</TouchableOpacity>
{(this.state.streamingMode || (canLoadMedia && fileInfo && isPlayable)) && (
<View
style={playerBgStyle}
ref={ref => {
this.playerBackground = ref;
}}
onLayout={evt => {
if (!this.state.playerBgHeight) {
this.setState({ playerBgHeight: evt.nativeEvent.layout.height });
}
}}
/>
)}
{(this.state.streamingMode || (canLoadMedia && fileInfo && isPlayable)) && this.state.fullscreenMode && (
<View style={fsPlayerBgStyle} />
)}
{(this.state.streamingMode || (canLoadMedia && fileInfo && isPlayable)) && (
<MediaPlayer
claim={claim}
assignPlayer={ref => {
this.player = ref;
}}
uri={uri}
source={this.playerUriForFileInfo(fileInfo)}
style={playerStyle}
autoPlay={autoplay || this.state.autoPlayMedia}
onFullscreenToggled={this.handleFullscreenToggle}
onLayout={evt => {
if (!this.state.playerHeight) {
this.setState({ playerHeight: evt.nativeEvent.layout.height });
}
}}
onMediaLoaded={() => this.onMediaLoaded(channelName, title, uri)}
onBackButtonPressed={this.onBackButtonPressed}
onPlaybackStarted={this.onPlaybackStarted}
onPlaybackFinished={this.onPlaybackFinished}
thumbnail={thumbnail} thumbnail={thumbnail}
position={position}
/> />
)} )}
{!unsupported &&
(!this.state.downloadButtonShown || this.state.downloadPressed) &&
!this.state.mediaLoaded && (
<ActivityIndicator size="large" color={Colors.NextLbryGreen} style={filePageStyle.loading} />
)}
{unsupported && fileInfo && completed && (
<View style={filePageStyle.unsupportedContent}>
<Image
style={filePageStyle.unsupportedContentImage}
resizeMode={'stretch'}
source={require('../../assets/gerbil-happy.png')}
/>
<View style={filePageStyle.unspportedContentTextContainer}>
<Text style={filePageStyle.unsupportedContentTitle}>{__('Unsupported Content')}</Text>
<Text style={filePageStyle.unsupportedContentText}>
Sorry, we are unable to display this content in the app. You can find the file named{' '}
<Text style={filePageStyle.unsupportedContentFilename}>{fileInfo.file_name}</Text> in your
downloads folder.
</Text>
</View>
</View>
)}
{((isPlayable && !completed && !canLoadMedia) ||
canOpen ||
(!completed && !this.state.streamingMode)) && (
<FileDownloadButton
uri={claim && claim.permanent_url ? claim.permanent_url : uri}
style={filePageStyle.downloadButton}
openFile={() => this.openFile(localFileUri, mediaType)}
isPlayable={isPlayable}
isViewable={isViewable}
onFileActionPress={this.onFileDownloadButtonPressed}
onButtonLayout={() => this.setState({ downloadButtonShown: true })}
/>
)}
{!fileInfo && (
<FilePrice uri={uri} style={filePageStyle.filePriceContainer} textStyle={filePageStyle.filePriceText} />
)}
<TouchableOpacity style={filePageStyle.backButton} onPress={this.onBackButtonPressed}>
<Icon name={'arrow-left'} size={18} style={filePageStyle.backButtonIcon} />
</TouchableOpacity>
</TouchableOpacity>
{!innerContent && (this.state.streamingMode || (canLoadMedia && fileInfo && isPlayable)) && (
<View
style={playerBgStyle}
ref={ref => {
this.playerBackground = ref;
}}
onLayout={evt => {
if (!this.state.playerBgHeight) {
this.setState({ playerBgHeight: evt.nativeEvent.layout.height });
}
}}
/>
)}
{!innerContent &&
(this.state.streamingMode || (canLoadMedia && fileInfo && isPlayable)) &&
this.state.fullscreenMode && <View style={fsPlayerBgStyle} />}
{!innerContent && (this.state.streamingMode || (canLoadMedia && fileInfo && isPlayable)) && (
<MediaPlayer
claim={claim}
assignPlayer={ref => {
this.player = ref;
}}
uri={uri}
source={this.playerUriForFileInfo(fileInfo)}
style={playerStyle}
autoPlay
onFullscreenToggled={this.handleFullscreenToggle}
onLayout={evt => {
if (!this.state.playerHeight) {
this.setState({ playerHeight: evt.nativeEvent.layout.height });
}
}}
onMediaLoaded={() => this.onMediaLoaded(channelName, title, uri)}
onBackButtonPressed={this.onBackButtonPressed}
onPlaybackStarted={this.onPlaybackStarted}
onPlaybackFinished={this.onPlaybackFinished}
thumbnail={thumbnail}
position={position}
/>
)}
{!innerContent && (
<ScrollView <ScrollView
style={filePageStyle.scrollContainer} style={filePageStyle.scrollContainer}
contentContainerstyle={showActions ? null : filePageStyle.scrollContent} contentContainerstyle={showActions ? null : filePageStyle.scrollContent}
@@ -1088,7 +1113,7 @@ class FilePage extends React.PureComponent {
normalizeURI(shortChannelUri || fullChannelUri), normalizeURI(shortChannelUri || fullChannelUri),
null, null,
false, false,
fullChannelUri fullChannelUri,
); );
}} }}
/> />
@@ -1101,7 +1126,7 @@ class FilePage extends React.PureComponent {
<DateTime <DateTime
style={filePageStyle.publishDate} style={filePageStyle.publishDate}
textStyle={filePageStyle.publishDateText} textStyle={filePageStyle.publishDateText}
uri={uri} uri={fullUri}
formatOptions={{ day: 'numeric', month: 'long', year: 'numeric' }} formatOptions={{ day: 'numeric', month: 'long', year: 'numeric' }}
show={DateTime.SHOW_DATE} show={DateTime.SHOW_DATE}
/> />
@@ -1156,34 +1181,29 @@ class FilePage extends React.PureComponent {
<View onLayout={this.setRelatedContentPosition} /> <View onLayout={this.setRelatedContentPosition} />
{isSearchingRecommendContent && ( {this.state.showRecommended && (
<ActivityIndicator size="small" color={Colors.NextLbryGreen} style={filePageStyle.relatedLoading} /> <RelatedContent navigation={navigation} title={title} uri={fullUri} fullUri={fullUri} />
)}
{!isSearchingRecommendContent && recommendedContent && recommendedContent.length > 0 && (
<RelatedContent navigation={navigation} uri={uri} fullUri={fullUri} />
)} )}
</ScrollView> </ScrollView>
</View> )}
)} </View>
{this.state.showTipView && ( )}
<ModalTipView {this.state.showTipView && (
claim={claim} <ModalTipView
channelName={channelName} claim={claim}
contentName={title} channelName={channelName}
onCancelPress={() => this.setState({ showTipView: false })} contentName={title}
onOverlayPress={() => this.setState({ showTipView: false })} onCancelPress={() => this.setState({ showTipView: false })}
onSendTipSuccessful={() => this.setState({ showTipView: false })} onOverlayPress={() => this.setState({ showTipView: false })}
/> onSendTipSuccessful={() => this.setState({ showTipView: false })}
)} />
{!this.state.fullscreenMode && )}
!this.state.showTipView && {!this.state.fullscreenMode &&
!this.state.showImageViewer && !this.state.showTipView &&
!this.state.showWebView && <FloatingWalletBalance navigation={navigation} />} !this.state.showImageViewer &&
</View> !this.state.showWebView && <FloatingWalletBalance navigation={navigation} />}
); </View>
} );
return null;
} }
} }
+14 -3
View File
@@ -228,7 +228,13 @@ class FirstRunScreen extends React.PureComponent {
handleContinuePressed = () => { handleContinuePressed = () => {
const { notify, user, hasSyncedWallet } = this.props; const { notify, user, hasSyncedWallet } = this.props;
const pageIndex = FirstRunScreen.pages.indexOf(this.state.currentPage); const pageIndex = FirstRunScreen.pages.indexOf(this.state.currentPage);
if (Constants.FIRST_RUN_PAGE_WALLET === this.state.currentPage) {
if (Constants.FIRST_RUN_PAGE_WELCOME === this.state.currentPage) {
// only show the welcome screen on first run
this.closeFinalPage();
}
/* if (Constants.FIRST_RUN_PAGE_WALLET === this.state.currentPage) {
// do apply sync to check if the password is valid // do apply sync to check if the password is valid
if (hasSyncedWallet) { if (hasSyncedWallet) {
this.checkWalletPassword(); this.checkWalletPassword();
@@ -256,7 +262,7 @@ class FirstRunScreen extends React.PureComponent {
} else { } else {
this.showNextPage(); this.showNextPage();
} }
} } */
}; };
handleEmailCollectPageContinue() { handleEmailCollectPageContinue() {
@@ -500,7 +506,12 @@ class FirstRunScreen extends React.PureComponent {
{Constants.FIRST_RUN_PAGE_SKIP_ACCOUNT !== this.state.currentPage && {Constants.FIRST_RUN_PAGE_SKIP_ACCOUNT !== this.state.currentPage &&
Constants.FIRST_RUN_PAGE_EMAIL_VERIFY !== this.state.currentPage && ( Constants.FIRST_RUN_PAGE_EMAIL_VERIFY !== this.state.currentPage && (
<Text style={firstRunStyle.buttonText}> <Text style={firstRunStyle.buttonText}>
{Constants.FIRST_RUN_PAGE_WALLET === this.state.currentPage ? __('Use LBRY') : __('Continue')} » {[Constants.FIRST_RUN_PAGE_WALLET, Constants.FIRST_RUN_PAGE_WELCOME].includes(
this.state.currentPage
)
? __('Use LBRY')
: __('Continue')}{' '}
»
</Text> </Text>
)} )}
</TouchableOpacity> </TouchableOpacity>
+6 -4
View File
@@ -1,14 +1,15 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { import {
doClaimSearch, doClaimSearch,
doResolveUris,
doSearch, doSearch,
doUpdateSearchQuery, doUpdateSearchQuery,
makeSelectSearchUris, makeSelectSearchUris,
selectClaimSearchByQuery, selectClaimSearchByQuery,
selectIsSearching, selectIsSearching,
selectResolvingUris,
selectSearchValue, selectSearchValue,
makeSelectQueryWithOptions, makeSelectQueryWithOptions,
selectSearchUrisByQuery,
} from 'lbry-redux'; } from 'lbry-redux';
import { doPushDrawerStack, doSetPlayerVisible } from 'redux/actions/drawer'; import { doPushDrawerStack, doSetPlayerVisible } from 'redux/actions/drawer';
import { selectCurrentRoute } from 'redux/selectors/drawer'; import { selectCurrentRoute } from 'redux/selectors/drawer';
@@ -22,19 +23,20 @@ const select = state => ({
currentRoute: selectCurrentRoute(state), currentRoute: selectCurrentRoute(state),
isSearching: selectIsSearching(state), isSearching: selectIsSearching(state),
query: selectSearchValue(state), query: selectSearchValue(state),
resolvingUris: selectResolvingUris(state),
uris: makeSelectSearchUris(makeSelectQueryWithOptions(null, numSearchResults)(state))(state), uris: makeSelectSearchUris(makeSelectQueryWithOptions(null, numSearchResults)(state))(state),
urisByQuery: selectSearchUrisByQuery(state),
}); });
const perform = dispatch => ({ const perform = dispatch => ({
search: query => dispatch(doSearch(query, numSearchResults)), search: query => dispatch(doSearch(query, numSearchResults, null, false, false)),
claimSearch: options => dispatch(doClaimSearch(options)), claimSearch: options => dispatch(doClaimSearch(options)),
updateSearchQuery: query => dispatch(doUpdateSearchQuery(query)), updateSearchQuery: query => dispatch(doUpdateSearchQuery(query)),
pushDrawerStack: () => dispatch(doPushDrawerStack(Constants.DRAWER_ROUTE_SEARCH)), pushDrawerStack: () => dispatch(doPushDrawerStack(Constants.DRAWER_ROUTE_SEARCH)),
resolveUris: uris => dispatch(doResolveUris(uris)),
setPlayerVisible: () => dispatch(doSetPlayerVisible(false)), setPlayerVisible: () => dispatch(doSetPlayerVisible(false)),
}); });
export default connect( export default connect(
select, select,
perform perform,
)(SearchPage); )(SearchPage);
+56 -19
View File
@@ -26,6 +26,7 @@ class SearchPage extends React.PureComponent {
showTagResult: false, showTagResult: false,
claimSearchRun: false, claimSearchRun: false,
claimSearchOptions: null, claimSearchOptions: null,
resultsResolved: false,
}; };
static navigationOptions = { static navigationOptions = {
@@ -58,6 +59,7 @@ class SearchPage extends React.PureComponent {
claimSearchOptions: null, claimSearchOptions: null,
claimSearchRun: false, claimSearchRun: false,
showTagResult: false, showTagResult: false,
resultsResolved: false,
}); });
search(searchQuery); search(searchQuery);
} }
@@ -80,11 +82,44 @@ class SearchPage extends React.PureComponent {
this.setState({ this.setState({
currentQuery: query, currentQuery: query,
currentUri: isURIValid(query) ? normalizeURI(query) : null, currentUri: isURIValid(query) ? normalizeURI(query) : null,
resultsResolved: false,
}); });
search(query); search(query);
} }
} }
allContentResolved() {
const { uris, resolvingUris } = this.props;
if (!this.state.resultsResolved) {
return false;
}
if (uris) {
let allResolved = true;
uris.forEach(uri => {
allResolved = allResolved && !resolvingUris.includes(uri);
});
return allResolved;
}
return false;
}
shouldComponentUpdate() {
const { isSearching, uris } = this.props;
return (isSearching && (!uris || uris.length === 0)) || (!isSearching && this.allContentResolved());
}
componentDidUpdate() {
const { isSearching, resolveUris, uris } = this.props;
if (!isSearching && !this.state.resultsResolved) {
this.setState({ resultsResolved: true }, () => {
if (uris && uris.length > 0) {
resolveUris(uris);
}
});
}
}
getSearchQuery() { getSearchQuery() {
const { navigation } = this.props; const { navigation } = this.props;
if (navigation && navigation.state && navigation.state.params) { if (navigation && navigation.state && navigation.state.params) {
@@ -130,11 +165,11 @@ class SearchPage extends React.PureComponent {
this.setState({ claimSearchOptions: options, claimSearchRun: true }, () => claimSearch(options)); this.setState({ claimSearchOptions: options, claimSearchRun: true }, () => claimSearch(options));
} }
if (this.state.claimSearchRun && this.state.claimSearchOptions) { /* if (this.state.claimSearchRun && this.state.claimSearchOptions) {
const claimSearchKey = createNormalizedClaimSearchKey(this.state.claimSearchOptions); const claimSearchKey = createNormalizedClaimSearchKey(this.state.claimSearchOptions);
const claimSearchUris = claimSearchByQuery[claimSearchKey]; const claimSearchUris = claimSearchByQuery[claimSearchKey];
this.setState({ showTagResult: claimSearchUris && claimSearchUris.length > 0 }); this.setState({ showTagResult: claimSearchUris && claimSearchUris.length > 0 });
} } */
return ( return (
<View> <View>
@@ -155,7 +190,7 @@ class SearchPage extends React.PureComponent {
}; };
render() { render() {
const { isSearching, navigation, query, uris, urisByQuery } = this.props; const { isSearching, navigation, query, uris } = this.props;
return ( return (
<View style={searchStyle.container}> <View style={searchStyle.container}>
@@ -167,22 +202,24 @@ class SearchPage extends React.PureComponent {
</View> </View>
)} )}
<FlatList {!isSearching && (
extraData={this.state} <FlatList
style={searchStyle.scrollContainer} extraData={this.state}
contentContainerStyle={searchStyle.scrollPadding} style={searchStyle.scrollContainer}
keyboardShouldPersistTaps={'handled'} contentContainerStyle={searchStyle.scrollPadding}
data={uris} keyboardShouldPersistTaps={'handled'}
keyExtractor={(item, index) => item} data={uris}
initialNumToRender={10} keyExtractor={(item, index) => item}
maxToRenderPerBatch={20} initialNumToRender={8}
removeClippedSubviews maxToRenderPerBatch={20}
ListEmptyComponent={!isSearching ? this.listEmptyComponent() : null} removeClippedSubviews
ListHeaderComponent={this.state.currentUri ? this.listHeaderComponent(this.state.showTagResult) : null} ListEmptyComponent={!isSearching ? this.listEmptyComponent() : null}
renderItem={({ item }) => ( ListHeaderComponent={this.state.currentUri ? this.listHeaderComponent(this.state.showTagResult) : null}
<FileListItem key={item} uri={item} style={searchStyle.resultItem} navigation={navigation} /> renderItem={({ item }) => (
)} <FileListItem key={item} uri={item} style={searchStyle.resultItem} batchResolve navigation={navigation} />
/> )}
/>
)}
<FloatingWalletBalance navigation={navigation} /> <FloatingWalletBalance navigation={navigation} />
</View> </View>
); );
+5 -5
View File
@@ -115,7 +115,7 @@ class SplashScreen extends React.PureComponent {
}, },
error => { error => {
/* failed */ /* failed */
} },
); );
}; };
@@ -293,7 +293,7 @@ class SplashScreen extends React.PureComponent {
isLagging: true, isLagging: true,
message: __('Connection Failure'), message: __('Connection Failure'),
details: __( details: __(
'We could not establish a connection to the SDK. Your data connection may be preventing LBRY from connecting. Contact hello@lbry.com if you think this is a software bug.' 'We could not establish a connection to the SDK. Your data connection may be preventing LBRY from connecting. Contact hello@lbry.com if you think this is a software bug.',
), ),
}); });
}); });
@@ -318,7 +318,7 @@ class SplashScreen extends React.PureComponent {
message: __('Testing network'), message: __('Testing network'),
details: __('Waiting for name resolution'), details: __('Waiting for name resolution'),
}, },
() => this.finishSplashScreen() () => this.finishSplashScreen(),
); );
}; };
@@ -331,12 +331,12 @@ class SplashScreen extends React.PureComponent {
<Text style={splashStyle.errorTitle}>{__('Oops! Something went wrong.')}</Text> <Text style={splashStyle.errorTitle}>{__('Oops! Something went wrong.')}</Text>
<Text style={splashStyle.paragraph}> <Text style={splashStyle.paragraph}>
{__( {__(
'Your wallet failed to unlock, which means you may not be able to play any videos or access your funds.' 'Your wallet failed to unlock, which means you may not be able to play any videos or access your funds.',
)} )}
</Text> </Text>
<Text style={splashStyle.paragraph}> <Text style={splashStyle.paragraph}>
{__( {__(
'You can try to fix this by tapping Stop on the LBRY service notification and starting the app again. If the problem continues, you may have to reinstall the app and restore your account.' 'You can try to fix this by tapping Stop on the LBRY service notification and starting the app again. If the problem continues, you may have to reinstall the app and restore your account.',
)} )}
</Text> </Text>
+5
View File
@@ -94,6 +94,11 @@ const fileListStyle = StyleSheet.create({
top: 8, top: 8,
left: 8, left: 8,
}, },
featuredDownloadedIcon: {
position: 'absolute',
left: 16,
top: 16,
},
fileItem: { fileItem: {
marginLeft: 24, marginLeft: 24,
marginRight: 24, marginRight: 24,