Compare commits

..
Author SHA1 Message Date
Akinwale Ariwodola 8ae6b88410 fix downloads. file page tweaks. 2019-12-28 10:59:30 +01:00
Akinwale Ariwodola a32c7f32f8 download button tweaks 2019-12-28 01:12:07 +01:00
Akinwale Ariwodola c1f73c2766 streamlined first run 2019-12-28 00:46:11 +01:00
37 changed files with 2373 additions and 4670 deletions

No files matched your search

-4
View File
@@ -1,7 +1,3 @@
if (__DEV__) {
import('./reactotron').then(() => console.log('Reactotron Configured'));
}
import LBRYApp from './src/index';
export default LBRYApp;
+1 -6
View File
@@ -243,10 +243,5 @@
"Are you a supermodel or rockstar that received a custom reward code? Claim it here.": "Are you a supermodel or rockstar that received a custom reward code? Claim it here.",
"Redeem": "Redeem",
"Please confirm that you want to use LBRY without creating an account.": "Please confirm that you want to use LBRY without creating an account.",
"You sent %amount% LBC as a tip, Mahalo!": "You sent %amount% LBC as a tip, Mahalo!",
"%follower% follower": "%follower% follower",
"Authenticating": "Authenticating",
"Waiting for authentication": "Waiting for authentication",
"Delete file": "Delete file",
"Are you sure you want to remove this file from your device?": "Are you sure you want to remove this file from your device?"
"You sent %amount% LBC as a tip, Mahalo!": "You sent %amount% LBC as a tip, Mahalo!"
}
+1869 -3617
View File
File diff suppressed because it is too large. Load diff
+21 -29
View File
@@ -12,55 +12,50 @@
"base-64": "^0.1.0",
"@expo/vector-icons": "^8.1.0",
"gfycat-style-urls": "^1.0.3",
"lbry-redux": "lbryio/lbry-redux#c910cd2b80b165843a81fdf6ce96094429b94ec8",
"lbry-redux": "lbryio/lbry-redux#abe90e0665cfad3fb8853501ec058c5d1f0d9cc8",
"lbryinc": "lbryio/lbryinc#053ca52f4f7f9bf8eb62a3581b183671a475ad1c",
"lodash": ">=4.17.11",
"merge": ">=1.2.1",
"moment": "^2.22.1",
"react": "16.9.0",
"react-native": "0.61.5",
"react": "16.8.6",
"react-native": "0.59.10",
"@react-native-community/async-storage": "^1.5.1",
"@react-native-community/masked-view": "^0.1.5",
"react-native-camera": "^3.15.0",
"react-native-country-picker-modal": "^1.10.0",
"react-native-exception-handler": "2.10.8",
"react-native-fast-image": "^7.0.2",
"react-native-camera": "^2.11.1",
"react-native-country-picker-modal": "^0.6.2",
"react-native-exception-handler": "2.9.0",
"react-native-fast-image": "^6.1.1",
"react-native-fs": "^2.13.3",
"react-native-gesture-handler": "1.5.2",
"react-native-gesture-handler": "1.3.0",
"react-native-image-zoom-viewer": "^2.2.5",
"react-native-password-strength-meter": "^0.0.2",
"react-native-phone-input": "lbryio/react-native-phone-input",
"react-native-reanimated": "1.4.0",
"react-native-safe-area-context": "^0.6.2",
"react-native-snackbar": "2.0.4",
"react-native-reanimated": "1.2.0",
"react-native-snackbar": "1.0.2",
"react-native-super-grid": "^3.0.4",
"react-native-vector-icons": "^6.6.0",
"react-native-video": "lbryio/react-native-video#7992ff945872f9bd00a3736d9ff1318f343abf47",
"react-native-webview": "^8.0.2",
"react-navigation": "^4.0.10",
"react-native-video": "lbryio/react-native-video#exoplayer-lbry-android",
"react-navigation": "^3.11.0",
"react-navigation-drawer": "^1.4.0",
"react-navigation-redux-helpers": "^3.0.2",
"react-navigation-tabs": "^2.7.0",
"react-navigation-stack": "^1.10.3",
"react-navigation-stack": "^1.8.1",
"react-redux": "^5.0.3",
"redux": "^4.0.4",
"redux-persist": "^6.0.0",
"redux-persist-filesystem-storage": "^2.1.0",
"redux-persist": "^5.10.0",
"redux-persist-filesystem-storage": "^1.3.2",
"redux-persist-transform-compress": "^4.2.0",
"redux-persist-transform-filter": "0.0.18",
"redux-thunk": "^2.3.0",
"rn-fetch-blob": "0.12.0",
"seedrandom": "3.0.3",
"showdown": "1.9.1"
"rn-fetch-blob": "0.10.15",
"seedrandom": "3.0.3"
},
"devDependencies": {
"@babel/core": "^7.6.2",
"@babel/core": "^7.5.4",
"babel-eslint": "10.0.2",
"@babel/plugin-proposal-object-rest-spread": "^7.5.4",
"babel-preset-env": "^1.6.1",
"babel-preset-stage-2": "^6.18.0",
"babel-plugin-module-resolver": "^3.1.1",
"eslint": "^6.5.1",
"eslint": "^5.16.0",
"eslint-config-standard": "^12.0.0",
"eslint-config-standard-jsx": "^6.0.2",
"eslint-plugin-flowtype": "^2.46.1",
@@ -72,11 +67,8 @@
"flow-babel-webpack-plugin": "^1.1.1",
"husky": "^0.14.3",
"lint-staged": "^7.0.4",
"metro-react-native-babel-preset": "^0.56.0",
"metro-react-native-babel-preset": "^0.55.0",
"prettier": "^1.11.1",
"@react-native-community/eslint-config": "^0.0.5",
"react-devtools": "^3.6.3",
"reactotron-react-native": "4.0.2",
"reactotron-redux": "3.1.2"
"react-devtools": "^3.6.3"
}
}
-12
View File
@@ -1,12 +0,0 @@
import AsyncStorage from '@react-native-community/async-storage';
import Reactotron from 'reactotron-react-native';
import { reactotronRedux } from 'reactotron-redux';
const reactotron = 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
.use(reactotronRedux())
.connect();
export default reactotron;
+7 -8
View File
@@ -108,7 +108,7 @@ const discoverStack = createStackNavigator(
{
headerMode: 'screen',
transitionConfig: () => ({ screenInterpolator: () => null }),
},
}
);
discoverStack.navigationOptions = ({ navigation }) => {
@@ -142,7 +142,7 @@ const walletStack = createStackNavigator(
{
headerMode: 'screen',
transitionConfig: () => ({ screenInterpolator: () => null }),
},
}
);
const drawerIconSize = 18;
@@ -231,12 +231,11 @@ const drawer = createDrawerNavigator(
backBehavior: 'none',
unmountInactiveRoutes: true,
contentComponent: DrawerContent,
overlayColor: 'rgba(0, 0, 0, 0.7)',
contentOptions: {
activeTintColor: Colors.LbryGreen,
labelStyle: discoverStyle.menuText,
},
},
}
);
const mainStackNavigator = new createStackNavigator(
@@ -265,7 +264,7 @@ const mainStackNavigator = new createStackNavigator(
},
{
headerMode: 'none',
},
}
);
export const AppNavigator = mainStackNavigator;
@@ -304,7 +303,7 @@ class AppWithNavigationState extends React.Component {
}
return false;
}.bind(this),
}.bind(this)
);
}
@@ -347,7 +346,7 @@ class AppWithNavigationState extends React.Component {
},
error => {
/* failed */
},
}
);
};
@@ -520,7 +519,7 @@ class AppWithNavigationState extends React.Component {
dispatch(
doToast({
message: 'Invalid Verification URI',
}),
})
);
}
} else {
+1 -1
View File
@@ -10,7 +10,7 @@ import discoverStyle from 'styles/discover';
const groupedMenuItems = {
'Find content': [
{ icon: 'hashtag', label: 'Your Tags', route: Constants.DRAWER_ROUTE_DISCOVER },
{ icon: 'heart', solid: true, label: 'Following', route: Constants.DRAWER_ROUTE_SUBSCRIPTIONS },
{ icon: 'heart', solid: true, label: 'Subscriptions', route: Constants.DRAWER_ROUTE_SUBSCRIPTIONS },
{ icon: 'globe-americas', label: 'All Content', route: Constants.DRAWER_ROUTE_TRENDING },
],
'Your content': [
+12 -11
View File
@@ -30,6 +30,7 @@ class FileDownloadButton extends React.PureComponent {
fileInfo,
downloading,
uri,
purchaseUri,
costInfo,
isPlayable,
isViewable,
@@ -43,17 +44,7 @@ class FileDownloadButton extends React.PureComponent {
onButtonLayout,
} = this.props;
if (fileInfo && fileInfo.download_path && fileInfo.completed) {
return (
<TouchableOpacity
onLayout={onButtonLayout}
style={[style, fileDownloadButtonStyle.container]}
onPress={openFile}
>
<Text style={fileDownloadButtonStyle.text}>{isViewable ? __('View') : __('Open')}</Text>
</TouchableOpacity>
);
} else if ((fileInfo && !fileInfo.stopped) || loading || downloading) {
if ((fileInfo && !fileInfo.stopped) || loading || downloading) {
const progress = fileInfo && fileInfo.written_bytes ? (fileInfo.written_bytes / fileInfo.total_bytes) * 100 : 0,
label = fileInfo ? __('%progress%% complete', { progress: progress.toFixed(0) }) : __('Connecting...');
@@ -80,6 +71,16 @@ class FileDownloadButton extends React.PureComponent {
onPress={onFileActionPress}
/>
);
} else if (fileInfo && fileInfo.download_path) {
return (
<TouchableOpacity
onLayout={onButtonLayout}
style={[style, fileDownloadButtonStyle.container]}
onPress={openFile}
>
<Text style={fileDownloadButtonStyle.text}>{isViewable ? __('View') : __('Open')}</Text>
</TouchableOpacity>
);
}
return null;
+2 -7
View File
@@ -107,12 +107,7 @@ class FileItem extends React.PureComponent {
<Icon style={discoverStyle.downloadedIcon} solid color={Colors.NextLbryGreen} name={'folder'} size={16} />
)}
{!compactView && (!fileInfo || !fileInfo.completed || !fileInfo.download_path) && (
<FilePrice
uri={uri}
style={discoverStyle.filePriceContainer}
iconStyle={discoverStyle.filePriceIcon}
textStyle={discoverStyle.filePriceText}
/>
<FilePrice uri={uri} style={discoverStyle.filePriceContainer} textStyle={discoverStyle.filePriceText} />
)}
{!compactView && (
<View style={isRewardContent ? discoverStyle.rewardTitleContainer : null}>
@@ -134,7 +129,7 @@ class FileItem extends React.PureComponent {
normalizeURI(shortChannelUri || fullChannelUri),
null,
false,
fullChannelUri,
fullChannelUri
);
}}
/>
+2 -3
View File
@@ -61,7 +61,6 @@ class FileItemMedia extends React.PureComponent {
let style = this.props.style;
const { duration, isResolvingUri, thumbnail, title, resizeMode } = this.props;
const atStyle = this.state.autoThumbStyle;
const hasDuration = !!duration;
if (this.isThumbnailValid(thumbnail) && !this.state.imageLoadFailed) {
if (style == null) {
@@ -76,7 +75,7 @@ class FileItemMedia extends React.PureComponent {
resizeMode={this.getFastImageResizeMode(resizeMode)}
style={fileItemMediaStyle.image}
/>
{duration > 0 && (
{duration && (
<VideoDuration
duration={duration}
style={fileItemMediaStyle.duration}
@@ -105,7 +104,7 @@ class FileItemMedia extends React.PureComponent {
.toUpperCase()}
</Text>
)}
{duration > 0 && (
{duration && (
<VideoDuration
duration={duration}
style={fileItemMediaStyle.duration}
+1 -1
View File
@@ -36,5 +36,5 @@ const perform = dispatch => ({
export default connect(
select,
perform,
perform
)(FileListItem);
+4 -11
View File
@@ -6,7 +6,6 @@ import Colors from 'styles/colors';
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
import DateTime from 'component/dateTime';
import FileItemMedia from 'component/fileItemMedia';
import FilePrice from 'component/filePrice';
import Icon from 'react-native-vector-icons/FontAwesome5';
import Link from 'component/link';
import NsfwOverlay from 'component/nsfwOverlay';
@@ -48,8 +47,8 @@ class FileListItem extends React.PureComponent {
}
componentDidUpdate() {
const { claim, resolveUri, uri, batchResolve } = this.props;
if (!claim && uri !== this.state.url && !batchResolve) {
const { claim, resolveUri, uri } = this.props;
if (!claim && uri !== this.state.url) {
this.setState({ url: uri }, () => resolveUri(uri));
}
}
@@ -167,12 +166,6 @@ class FileListItem extends React.PureComponent {
size={16}
/>
)}
<FilePrice
uri={uri}
style={fileListStyle.filePriceContainer}
iconStyle={fileListStyle.filePriceIcon}
textStyle={fileListStyle.filePriceText}
/>
<View style={fileListStyle.detailsContainer}>
{featuredResult && (
<Text style={fileListStyle.featuredUri} numberOfLines={1}>
@@ -185,7 +178,7 @@ class FileListItem extends React.PureComponent {
{!title && !name && <Text style={fileListStyle.uri}>{uri}</Text>}
{!title && !name && (
<View style={fileListStyle.row}>
<ActivityIndicator size={'small'} color={featuredResult ? Colors.White : Colors.NextLbryGreen} />
<ActivityIndicator size={'small'} color={featuredResult ? Colors.White : Colors.LbryGreen} />
</View>
)}
</View>
@@ -216,7 +209,7 @@ class FileListItem extends React.PureComponent {
normalizeURI(shortChannelUri || fullChannelUri),
null,
false,
fullChannelUri,
fullChannelUri
);
}}
/>
+23 -21
View File
@@ -2,7 +2,6 @@ import React from 'react';
import PropTypes from 'prop-types';
import { Text, View } from 'react-native';
import { formatCredits, formatFullPrice } from 'lbry-redux';
import Icon from 'react-native-vector-icons/FontAwesome5';
class CreditAmount extends React.PureComponent {
static propTypes = {
@@ -63,27 +62,25 @@ class CreditAmount extends React.PureComponent {
}
}
return (
<Text style={style} numberOfLines={1}>
{amountText}
</Text>
);
/* {this.props.isEstimate ? (
<span
className="credit-amount__estimate"
title={__('This is an estimate and does not include data fees')}
>
*
</span>
) : null} */
return <Text style={style}>{amountText}</Text>;
}
}
class FilePrice extends React.PureComponent {
componentWillMount() {
const { cost } = this.props;
if (isNaN(parseFloat(cost))) {
this.fetchCost(this.props);
}
this.fetchCost(this.props);
}
componentWillReceiveProps(nextProps) {
const { cost } = this.props;
if (isNaN(parseFloat(cost))) {
this.fetchCost(nextProps);
}
this.fetchCost(nextProps);
}
fetchCost(props) {
@@ -95,25 +92,30 @@ class FilePrice extends React.PureComponent {
}
render() {
const { cost, costInfo, look = 'indicator', showFullPrice = false, style, iconStyle, textStyle } = this.props;
const { costInfo, look = 'indicator', showFullPrice = false, style, textStyle } = this.props;
const isEstimate = costInfo ? !costInfo.includesData : null;
const amount = cost ? parseFloat(cost) : costInfo ? parseFloat(costInfo.cost) : 0;
if (isNaN(amount) || amount === 0) {
return null;
if (!costInfo) {
return (
<View style={style}>
<Text style={textStyle}>???</Text>
</View>
);
}
return (
<View style={style}>
<Icon name="coins" size={9} style={iconStyle} />
<CreditAmount
style={textStyle}
label={false}
amount={amount}
amount={parseFloat(costInfo.cost)}
isEstimate={isEstimate}
showFree
showFullPrice={showFullPrice}
/>
>
???
</CreditAmount>
</View>
);
}
-40
View File
@@ -1,40 +0,0 @@
import { connect } from 'react-redux';
import {
doResolveUri,
makeSelectClaimForUri,
makeSelectMetadataForUri,
makeSelectFileInfoForUri,
makeSelectIsUriResolving,
makeSelectClaimIsNsfw,
makeSelectShortUrlForUri,
makeSelectTitleForUri,
makeSelectThumbnailForUri,
} from 'lbry-redux';
import { selectBlackListedOutpoints, selectFilteredOutpoints, selectRewardContentClaimIds } from 'lbryinc';
import { selectShowNsfw } from 'redux/selectors/settings';
import FileResultItem from './view';
const select = (state, props) => ({
blackListedOutpoints: selectBlackListedOutpoints(state),
claim: makeSelectClaimForUri(props.uri)(state),
fileInfo: makeSelectFileInfoForUri(props.uri)(state),
filteredOutpoints: selectFilteredOutpoints(state),
isDownloaded: !!makeSelectFileInfoForUri(props.uri)(state),
metadata: makeSelectMetadataForUri(props.uri)(state),
nsfw: makeSelectClaimIsNsfw(props.uri)(state),
isResolvingUri: makeSelectIsUriResolving(props.uri)(state),
obscureNsfw: !selectShowNsfw(state),
rewardedContentClaimIds: selectRewardContentClaimIds(state),
shortUrl: makeSelectShortUrlForUri(props.uri)(state),
title: makeSelectTitleForUri(props.uri)(state),
thumbnail: makeSelectThumbnailForUri(props.uri)(state),
});
const perform = dispatch => ({
resolveUri: uri => dispatch(doResolveUri(uri)),
});
export default connect(
select,
perform,
)(FileResultItem);
-146
View File
@@ -1,146 +0,0 @@
import React from 'react';
import { normalizeURI, parseURI } from 'lbry-redux';
import { ActivityIndicator, Platform, Text, TouchableOpacity, View } from 'react-native';
import { navigateToUri, formatBytes } from 'utils/helper';
import Colors from 'styles/colors';
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
import DateTime from 'component/dateTime';
import FileItemMedia from 'component/fileItemMedia';
import FilePrice from 'component/filePrice';
import Icon from 'react-native-vector-icons/FontAwesome5';
import Link from 'component/link';
import NsfwOverlay from 'component/nsfwOverlay';
import ProgressBar from 'component/progressBar';
import fileListStyle from 'styles/fileList';
class FileResultItem extends React.PureComponent {
getStorageForFileInfo = fileInfo => {
if (!fileInfo.completed) {
const written = formatBytes(fileInfo.written_bytes);
const total = formatBytes(fileInfo.total_bytes);
return `(${written} / ${total})`;
}
return formatBytes(fileInfo.written_bytes);
};
formatTitle = title => {
if (!title) {
return title;
}
return title.length > 80 ? title.substring(0, 77).trim() + '...' : title;
};
getDownloadProgress = fileInfo => {
return Math.ceil((fileInfo.written_bytes / fileInfo.total_bytes) * 100);
};
onPressHandler = () => {
const { autoplay, navigation, result } = this.props;
const { claimId, name } = result;
const url = normalizeURI(`${name}#${claimId}`);
navigateToUri(navigation, url, { autoplay }, false, url);
};
render() {
const { featuredResult, fileInfo, navigation, obscureNsfw, result, rewardedContentClaimIds, style } = this.props;
const {
channel,
channel_claim_id: channelClaimId,
claimId,
duration,
fee,
name,
nsfw,
release_time: releaseTime,
thumbnail_url: thumbnailUrl,
title,
} = result;
const obscure = obscureNsfw && nsfw;
const url = normalizeURI(`${name}#${claimId}`);
const hasChannel = !!channel;
const channelUrl = channel ? normalizeURI(`${channel}#${channelClaimId}`) : null;
const isRewardContent = rewardedContentClaimIds.includes(claimId);
return (
<View style={style}>
<TouchableOpacity style={style} onPress={this.onPressHandler}>
<FileItemMedia
style={fileListStyle.thumbnail}
duration={duration}
resizeMode="cover"
title={title || name || normalizeURI(url).substring(7)}
thumbnail={thumbnailUrl}
/>
{fileInfo && fileInfo.completed && fileInfo.download_path && (
<Icon
style={featuredResult ? fileListStyle.featuredDownloadedIcon : fileListStyle.downloadedIcon}
solid
color={Colors.NextLbryGreen}
name={'folder'}
size={16}
/>
)}
<FilePrice
cost={fee ? parseFloat(fee) / 100000000 : 0}
uri={url}
style={fileListStyle.filePriceContainer}
iconStyle={fileListStyle.filePriceIcon}
textStyle={fileListStyle.filePriceText}
/>
<View style={fileListStyle.detailsContainer}>
{(title || name) && (
<View style={fileListStyle.titleContainer}>
<Text style={featuredResult ? fileListStyle.featuredTitle : fileListStyle.title}>
{this.formatTitle(title) || this.formatTitle(name)}
</Text>
{isRewardContent && <Icon style={fileListStyle.rewardIcon} name="award" size={12} />}
</View>
)}
{hasChannel && (
<Link
style={fileListStyle.publisher}
text={channel}
onPress={() => {
navigateToUri(navigation, normalizeURI(channelUrl), null, false, channelUrl);
}}
/>
)}
<View style={fileListStyle.info}>
{fileInfo && !isNaN(fileInfo.written_bytes) && fileInfo.written_bytes > 0 && (
<Text>{this.getStorageForFileInfo(fileInfo)}</Text>
)}
<DateTime
style={fileListStyle.publishInfo}
textStyle={fileListStyle.infoText}
timeAgo
date={releaseTime}
/>
</View>
{fileInfo && fileInfo.download_path && (
<View style={fileListStyle.downloadInfo}>
{!fileInfo.completed && (
<ProgressBar
borderRadius={3}
color={Colors.NextLbryGreen}
height={3}
style={fileListStyle.progress}
progress={this.getDownloadProgress(fileInfo)}
/>
)}
</View>
)}
</View>
</TouchableOpacity>
{obscure && <NsfwOverlay onPress={() => navigation.navigate({ routeName: 'Settings', key: 'settingsPage' })} />}
</View>
);
}
}
export default FileResultItem;
+5 -10
View File
@@ -1,30 +1,25 @@
import { connect } from 'react-redux';
import {
doResolveUris,
doResolvedSearch,
makeSelectClaimForUri,
makeSelectResolvedRecommendedContentForUri,
selectResolvingUris,
makeSelectRecommendedContentForUri,
makeSelectTitleForUri,
selectIsSearching,
} from 'lbry-redux';
import RelatedContent from './view';
const RESULT_SIZE = 16;
const select = (state, props) => ({
claim: makeSelectClaimForUri(props.uri)(state),
recommendedContent: makeSelectRecommendedContentForUri(props.uri)(state),
title: makeSelectTitleForUri(props.uri)(state),
isSearching: selectIsSearching(state),
recommendedContent: makeSelectResolvedRecommendedContentForUri(props.uri, RESULT_SIZE)(state),
resolvingUris: selectResolvingUris(state),
});
const perform = dispatch => ({
resolveUris: uris => dispatch(doResolveUris(uris)),
searchRecommended: (query, claimId) =>
dispatch(doResolvedSearch(query, RESULT_SIZE, undefined, true, { related_to: claimId }, false)),
});
export default connect(
select,
perform,
perform
)(RelatedContent);
+17 -20
View File
@@ -4,40 +4,37 @@ import { normalizeURI } from 'lbry-redux';
import { navigateToUri } from 'utils/helper';
import Colors from 'styles/colors';
import FileListItem from 'component/fileListItem';
import FileResultItem from 'component/fileResultItem';
import fileListStyle from 'styles/fileList';
import relatedContentStyle from 'styles/relatedContent';
export default class RelatedContent extends React.PureComponent {
componentDidMount() {
const { title, claimId, searchRecommended } = this.props;
if (title && claimId) {
searchRecommended(title, claimId);
const { resolveUris, recommendedContent } = this.props;
if (recommendedContent && recommendedContent.length > 0) {
// batch resolve the uris
resolveUris(recommendedContent);
}
}
shouldComponentUpdate(nextProps, nextState) {
const { isSearching, recommendedContent } = nextProps;
return isSearching || (!isSearching && recommendedContent && recommendedContent.length > 0);
}
render() {
const { isSearching, recommendedContent, navigation, uri, fullUri } = this.props;
const { recommendedContent, navigation, uri, fullUri } = this.props;
return (
<View style={relatedContentStyle.container}>
<Text style={relatedContentStyle.title}>{__('Related Content')}</Text>
{isSearching && <ActivityIndicator size={'small'} color={Colors.NextLbryGreen} />}
{recommendedContent &&
recommendedContent.map(result => (
<FileResultItem
style={fileListStyle.item}
key={result.claimId}
result={result}
navigation={navigation}
autoplay
/>
))}
recommendedContent
.filter(recommendedUri => recommendedUri !== normalizeURI(fullUri))
.map(recommendedUri => (
<FileListItem
style={fileListStyle.item}
key={recommendedUri}
uri={recommendedUri}
batchResolve
navigation={navigation}
autoplay
/>
))}
</View>
);
}
+23 -35
View File
@@ -18,20 +18,18 @@ class UriBar extends React.PureComponent {
keyboardDidHideListener = null;
changeTextTimeout = -1;
state = {
changeTextTimeout: null,
currentValue: null,
inputText: null,
focused: false,
keyboardHeight: 0,
selection: undefined,
};
componentDidMount() {
this.keyboardDidShowListener = Keyboard.addListener('keyboardDidShow', this._keyboardDidShow);
this.keyboardDidHideListener = Keyboard.addListener('keyboardDidHide', this._keyboardDidHide);
this.setState({ selection: { start: 0, end: 0 } });
this.setSelection();
}
componentWillUnmount() {
@@ -53,14 +51,15 @@ class UriBar extends React.PureComponent {
}
handleChangeText = text => {
this.setState({ selection: undefined });
const newValue = text || '';
clearTimeout(this.changeTextTimeout);
clearTimeout(this.state.changeTextTimeout);
const { updateSearchQuery, onSearchSubmitted, showUriBarSuggestions, navigation } = this.props;
this.changeTextTimeout = -1;
updateSearchQuery(text);
let timeout = -1;
if (!showUriBarSuggestions) {
this.changeTextTimeout = setTimeout(() => {
timeout = setTimeout(() => {
if (text.trim().length === 0) {
// don't do anything if the text is empty
return;
@@ -68,7 +67,6 @@ class UriBar extends React.PureComponent {
if (!text.startsWith('lbry://')) {
// not a URI input, so this is a search, perform a direct search
updateSearchQuery(text);
if (onSearchSubmitted) {
onSearchSubmitted(text);
} else {
@@ -76,10 +74,8 @@ class UriBar extends React.PureComponent {
}
}
}, UriBar.INPUT_TIMEOUT);
} else {
updateSearchQuery(text);
}
this.setState({ inputText: newValue, currentValue: newValue });
this.setState({ inputText: newValue, currentValue: newValue, changeTextTimeout: timeout });
};
handleItemPress = item => {
@@ -127,6 +123,12 @@ class UriBar extends React.PureComponent {
this.setState({ focused: false, keyboardHeight: 0 });
};
setSelection() {
if (this.textInput) {
this.textInput.setNativeProps({ selection: { start: 0, end: 0 } });
}
}
handleSubmitEditing = () => {
const { navigation, onSearchSubmitted, updateSearchQuery } = this.props;
if (this.state.inputText) {
@@ -157,26 +159,6 @@ class UriBar extends React.PureComponent {
}
};
handleFocus = () => {
this.setState(
{
focused: true,
},
() => {
this.setState({
selection: { start: 0, end: this.state.currentValue ? this.state.currentValue.length : 0 },
});
},
);
};
handleBlur = () => {
this.setState({
focused: false,
selection: { start: 0, end: 0 },
});
};
onSearchPageBlurred() {
this.setState({ currenValueSet: false });
}
@@ -270,7 +252,10 @@ class UriBar extends React.PureComponent {
}}
autoCorrect={false}
style={uriBarStyle.uriText}
selection={this.state.selection}
onLayout={() => {
this.setSelection();
}}
selectTextOnFocus
placeholder={__('Search movies, music, and more')}
underlineColorAndroid={'transparent'}
numberOfLines={1}
@@ -279,8 +264,11 @@ class UriBar extends React.PureComponent {
returnKeyType={'go'}
inlineImageLeft={'baseline_search_black_24'}
inlineImagePadding={16}
onFocus={this.handleFocus}
onBlur={this.handleBlur}
onFocus={() => this.setState({ focused: true })}
onBlur={() => {
this.setState({ focused: false });
this.setSelection();
}}
onChangeText={this.handleChangeText}
onSubmitEditing={this.handleSubmitEditing}
/>
+2 -6
View File
@@ -38,10 +38,9 @@ class WalletSend extends React.PureComponent<Props> {
handleSend = () => {
const { balance, sendToAddress, notify } = this.props;
const { address, amount } = this.state;
if (address && (!regexAddress.test(address) || address.substring(0, 1) === 'r')) {
if (address && !regexAddress.test(address)) {
notify({
message: __('The recipient address is not a valid LBRY address.'),
isError: true,
});
return;
}
@@ -49,7 +48,6 @@ class WalletSend extends React.PureComponent<Props> {
if (amount > balance) {
notify({
message: __('Insufficient credits'),
isError: true,
});
return;
}
@@ -74,7 +72,6 @@ class WalletSend extends React.PureComponent<Props> {
const { notify } = this.props;
notify({
message: __('The recipient address is not a valid LBRY address.'),
isError: true,
});
}
};
@@ -100,10 +97,9 @@ class WalletSend extends React.PureComponent<Props> {
this.setState({
address: value,
addressChanged: true,
addressValid: value.trim().length === 0 || (regexAddress.test(value) && !value.startsWith('r')),
addressValid: value.trim().length === 0 || regexAddress.test(value),
})
}
numberOfLines={1}
onBlur={this.handleAddressInputBlur}
onSubmitEditing={this.handleAddressInputSubmit}
placeholder={'bbFxRyXXXXXXXXXXXZD8nE7XTLUxYnddTs'}
+1 -1
View File
@@ -134,7 +134,7 @@ const Constants = {
ORDER_BY_EFFECTIVE_AMOUNT: 'effective_amount',
DEFAULT_PAGE_SIZE: 20,
DEFAULT_PAGE_SIZE: 10,
ALL_PLACEHOLDER: '_all',
+3 -4
View File
@@ -42,7 +42,6 @@ import AppWithNavigationState, {
} from 'component/AppNavigator';
import { REHYDRATE, PURGE, persistCombineReducers, persistStore } from 'redux-persist';
import { __ } from 'i18n';
import reactotron from '../reactotron';
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
import getStoredStateMigrateV4 from 'redux-persist/lib/integration/getStoredStateMigrateV4';
import FilesystemStorage from 'redux-persist-filesystem-storage';
@@ -180,7 +179,7 @@ const sharedStateCallback = ({ dispatch, getState }) => {
const emailVerified = selectUserVerifiedEmail(state);
if (syncEnabled && emailVerified) {
NativeModules.UtilityModule.getSecureValue(Constants.KEY_WALLET_PASSWORD).then(password =>
dispatch(doGetSync(password)),
dispatch(doGetSync(password))
);
}
};
@@ -196,11 +195,11 @@ const composeEnhancers = compose;
const store = createStore(
enableBatching(reducers),
{}, // initial state,
composeEnhancers(applyMiddleware(...middleware), reactotron.createEnhancer()),
composeEnhancers(applyMiddleware(...middleware))
);
window.store = store;
const persistor = persistStore(store, null, err => {
const persistor = persistStore(store, persistOptions, err => {
if (err) {
console.log('Unable to load saved SETTINGS');
}
+8 -44
View File
@@ -1,5 +1,5 @@
import React from 'react';
import { CLAIM_VALUES, Lbry, formatCredits, isNameValid, regexInvalidURI } from 'lbry-redux';
import { CLAIM_VALUES, formatCredits, isNameValid, regexInvalidURI } from 'lbry-redux';
import {
ActivityIndicator,
Alert,
@@ -225,9 +225,9 @@ export default class ChannelCreator extends React.PureComponent {
error => {
notify({ message: `The image could not be uploaded: ${error}` });
this.setState({ uploadingImage: false });
},
}
);
},
}
);
} else {
// could not determine the file path
@@ -489,12 +489,12 @@ export default class ChannelCreator extends React.PureComponent {
claim_id: claimId,
amount: newChannelBid,
},
optionalParams,
optionalParams
);
this.setState({ updateChannelStarted: true }, () => updateChannel(params));
} else {
this.setState({ creatingChannel: true }, () =>
createChannel(channelName, newChannelBid, optionalParams).then(success, failure),
createChannel(channelName, newChannelBid, optionalParams).then(success, failure)
);
}
};
@@ -527,7 +527,7 @@ export default class ChannelCreator extends React.PureComponent {
avatarImagePickerOpen: false,
coverImagePickerOpen: true,
},
() => this.checkStoragePermission(),
() => NativeModules.UtilityModule.openDocumentPicker('image/*')
);
};
@@ -543,7 +543,7 @@ export default class ChannelCreator extends React.PureComponent {
avatarImagePickerOpen: true,
coverImagePickerOpen: false,
},
() => this.checkStoragePermission(),
() => NativeModules.UtilityModule.openDocumentPicker('image/*')
);
};
@@ -673,7 +673,7 @@ export default class ChannelCreator extends React.PureComponent {
},
},
],
{ cancelable: true },
{ cancelable: true }
);
};
@@ -749,42 +749,6 @@ export default class ChannelCreator extends React.PureComponent {
this.addOrRemoveItem(channel);
};
checkStoragePermission = () => {
// 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 {
NativeModules.UtilityModule.openDocumentPicker('image/*');
}
});
};
handleStoragePermissionGranted = () => {
// update the configured download folder
NativeModules.UtilityModule.getDownloadDirectory().then(downloadDirectory => {
Lbry.settings_set({
key: 'download_dir',
value: downloadDirectory,
})
.then(() => {})
.catch(() => {});
});
// open picker for images
NativeModules.UtilityModule.openDocumentPicker('image/*');
};
handleStoragePermissionRefused = () => {
const { notify } = this.props;
notify({
message: __('Pictures from your device cannot be used because the permission to read storage was not granted.'),
isError: true,
});
this.setState({ avatarImagePickerOpen: false, coverImagePickerOpen: false });
};
render() {
const { abandoningClaimIds, balance, fetchingChannels, updatingChannel, channels = [], navigation } = this.props;
const {
+7 -1
View File
@@ -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);
+248 -351
View File
@@ -17,8 +17,8 @@ import {
TouchableOpacity,
TouchableWithoutFeedback,
View,
WebView,
} from 'react-native';
import { WebView } from 'react-native-webview';
import { NavigationEvents } from 'react-navigation';
import { navigateBack, navigateToUri, formatLbryUrlForWeb } from 'utils/helper';
import Icon from 'react-native-vector-icons/FontAwesome5';
@@ -45,8 +45,6 @@ import Video from 'react-native-video';
import FileRewardsDriver from 'component/fileRewardsDriver';
import filePageStyle from 'styles/filePage';
import uriBarStyle from 'styles/uriBar';
import RNFS from 'react-native-fs';
import showdown from 'showdown';
import _ from 'lodash';
class FilePage extends React.PureComponent {
@@ -60,10 +58,6 @@ class FilePage extends React.PureComponent {
startTime = null;
webView = null;
converter = null;
constructor(props) {
super(props);
this.state = {
@@ -93,7 +87,6 @@ class FilePage extends React.PureComponent {
playerHeight: 0,
uri: null,
uriVars: null,
showRecommended: false,
stopDownloadConfirmed: false,
streamingMode: false,
viewCountFetched: false,
@@ -119,8 +112,8 @@ class FilePage extends React.PureComponent {
if (!isResolvingUri && !claim) resolveUri(uri);
this.fetchFileInfo(uri, this.props);
this.fetchCostInfo(uri, this.props);
this.fetchFileInfo(this.props);
this.fetchCostInfo(this.props);
fetchMyClaims();
@@ -151,10 +144,10 @@ class FilePage extends React.PureComponent {
failedPurchaseUris: prevFailedPurchaseUris,
fetchViewCount,
purchasedUris: prevPurchasedUris,
purchaseUriErrorMessage: prevPurchaseUriErrorMessage,
navigation,
contentType,
notify,
recommendedContent: prevRecommendedContent,
drawerStack: prevDrawerStack,
} = this.props;
const { uri } = navigation.state.params;
@@ -166,6 +159,7 @@ class FilePage extends React.PureComponent {
purchaseUriErrorMessage,
streamingUrl,
drawerStack,
recommendedContent,
resolveUris,
} = nextProps;
@@ -173,11 +167,7 @@ class FilePage extends React.PureComponent {
this.onComponentFocused();
}
if (
failedPurchaseUris.includes(uri) &&
!purchasedUris.includes(uri) &&
prevPurchaseUriErrorMessage !== purchaseUriErrorMessage
) {
if (failedPurchaseUris.includes(uri) && !purchasedUris.includes(uri)) {
if (purchaseUriErrorMessage && purchaseUriErrorMessage.trim().length > 0) {
notify({ message: purchaseUriErrorMessage, isError: true });
}
@@ -223,6 +213,13 @@ class FilePage extends React.PureComponent {
if (claim && !this.state.viewCountFetched) {
this.setState({ viewCountFetched: true }, () => fetchViewCount(claim.claim_id));
}
if (
(!prevRecommendedContent && recommendedContent) ||
(recommendedContent && prevRecommendedContent && recommendedContent.length !== prevRecommendedContent.length)
) {
resolveUris(recommendedContent);
}
}
shouldComponentUpdate(nextProps, nextState) {
@@ -233,7 +230,17 @@ class FilePage extends React.PureComponent {
}
componentDidUpdate(prevProps, prevState) {
const { claim, contentType, costInfo, fileInfo, isResolvingUri, resolveUri, navigation, title } = this.props;
const {
claim,
contentType,
costInfo,
fileInfo,
isResolvingUri,
resolveUri,
navigation,
purchaseUri,
title,
} = this.props;
const { uri } = this.state;
if (!isResolvingUri && claim === undefined && uri) {
resolveUri(uri);
@@ -251,53 +258,31 @@ class FilePage extends React.PureComponent {
// attempt to retrieve images and html/text automatically once the claim is loaded, and it's free
const mediaType = Lbry.getMediaType(contentType);
const isPlayable = mediaType === 'video' || mediaType === 'audio';
const isViewable = mediaType === 'image' || mediaType === 'text';
if (claim && costInfo && costInfo.cost === 0 && !this.state.autoGetAttempted && isViewable) {
this.setState({ autoGetAttempted: true }, () => this.checkStoragePermissionForDownload());
}
if (((costInfo && costInfo.cost > 0) || !isPlayable) && !this.state.showRecommended) {
this.setState({ showRecommended: true });
}
if (
!fileInfo &&
!this.state.autoDownloadStarted &&
claim &&
costInfo &&
costInfo.cost === 0 &&
(isPlayable || (this.state.uriVars && this.state.uriVars.download === 'true'))
) {
this.setState({ autoDownloadStarted: true }, () => {
if (!isPlayable) {
this.checkStoragePermissionForDownload();
} else {
this.confirmPurchaseUri(claim.permanent_url, costInfo, !isPlayable);
}
NativeModules.UtilityModule.checkDownloads();
});
}
}
fetchFileInfo(uri, props) {
fetchFileInfo(props) {
if (props.fileInfo === undefined) {
props.fetchFileInfo(uri);
props.fetchFileInfo(props.navigation.state.params.uri);
}
}
fetchCostInfo(uri, props) {
fetchCostInfo(props) {
if (props.costInfo === undefined) {
props.fetchCostInfo(uri);
props.fetchCostInfo(props.navigation.state.params.uri);
}
}
handleFullscreenToggle = isFullscreen => {
const { toggleFullscreenMode } = this.props;
this.setState({ fullscreenMode: isFullscreen });
toggleFullscreenMode(isFullscreen);
StatusBar.setHidden(isFullscreen);
if (isFullscreen) {
// fullscreen, so change orientation to landscape mode
NativeModules.ScreenOrientation.lockOrientationLandscape();
@@ -308,11 +293,9 @@ class FilePage extends React.PureComponent {
// Switch back to portrait mode when the media is not fullscreen
NativeModules.ScreenOrientation.lockOrientationPortrait();
// show the navigation bar (on devices that have the soft navigation bar)
// hide the navigation bar (on devices that have the soft navigation bar)
NativeModules.UtilityModule.showNavigationBar();
}
StatusBar.setHidden(isFullscreen);
};
onEditPressed = () => {
@@ -324,12 +307,12 @@ class FilePage extends React.PureComponent {
const { abandonClaim, claim, deleteFile, deletePurchasedUri, myClaimUris, fileInfo, navigation } = this.props;
Alert.alert(
__('Delete file'),
__('Are you sure you want to remove this file from your device?'),
'Delete file',
'Are you sure you want to remove this file from your device?',
[
{ text: __('No') },
{ text: 'No' },
{
text: __('Yes'),
text: 'Yes',
onPress: () => {
const { uri } = navigation.state.params;
@@ -356,7 +339,7 @@ class FilePage extends React.PureComponent {
},
},
],
{ cancelable: true },
{ cancelable: true }
);
};
@@ -392,7 +375,7 @@ class FilePage extends React.PureComponent {
},
},
],
{ cancelable: true },
{ cancelable: true }
);
};
@@ -541,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;
@@ -560,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 = () => {
@@ -614,38 +600,6 @@ class FilePage extends React.PureComponent {
));
};
confirmPurchaseUri = (uri, costInfo, download) => {
const { notify, purchaseUri, title } = this.props;
const { cost } = costInfo;
if (!costInfo) {
notify({ message: __('This content cannot be viewed at this time. Please try again in a bit.'), isError: true });
return;
}
if (costInfo.cost > 0) {
Alert.alert(
__('Confirm Purchase'),
__(
cost === 1
? 'This will purchase "%title%" for %amount% credit'
: 'This will purchase "%title%" for %amount% credits',
{ title, amount: cost },
),
[
{
text: __('OK'),
onPress: () => purchaseUri(uri, costInfo, download),
},
{ text: __('Cancel') },
],
);
} else {
// Free content. Just call purchaseUri directly.
purchaseUri(uri, costInfo, download);
}
};
onFileDownloadButtonPressed = () => {
const { claim, costInfo, contentType, purchaseUri, setPlayerVisible } = this.props;
const mediaType = Lbry.getMediaType(contentType);
@@ -658,7 +612,7 @@ class FilePage extends React.PureComponent {
if (!isPlayable) {
this.checkStoragePermissionForDownload();
} else {
this.confirmPurchaseUri(uri, costInfo, !isPlayable);
purchaseUri(uri, costInfo, !isPlayable);
}
if (isPlayable) {
@@ -696,9 +650,9 @@ class FilePage extends React.PureComponent {
stopDownloadConfirmed: false,
},
() => {
this.confirmPurchaseUri(claim.permanent_url, costInfo, true);
purchaseUri(claim.permanent_url, costInfo, true);
NativeModules.UtilityModule.checkDownloads();
},
}
);
};
@@ -707,18 +661,6 @@ class FilePage extends React.PureComponent {
navigateBack(navigation, drawerStack, popDrawerStack);
};
onOpenFilePressed = () => {
const { contentType, fileInfo, notify } = this.props;
const localFileUri = this.localUriForFileInfo(fileInfo);
const mediaType = Lbry.getMediaType(contentType);
const isViewable = mediaType === 'image' || mediaType === 'text';
if (isViewable) {
this.openFile(localFileUri, mediaType, contentType);
} else {
notify({ message: __('This file cannot be displayed in the LBRY app.') });
}
};
onSaveFilePressed = () => {
const { costInfo, fileGet, fileInfo, navigation, purchasedUris, purchaseUri } = this.props;
const { uri } = navigation.state.params;
@@ -731,7 +673,7 @@ class FilePage extends React.PureComponent {
}
};
openFile = (localFileUri, mediaType, contentType) => {
openFile = (localFileUri, mediaType) => {
const { pushDrawerStack } = this.props;
const isWebViewable = mediaType === 'text';
@@ -747,7 +689,7 @@ class FilePage extends React.PureComponent {
],
showImageViewer: true,
},
() => pushDrawerStack(Constants.DRAWER_ROUTE_FILE_VIEW),
() => pushDrawerStack(Constants.DRAWER_ROUTE_FILE_VIEW)
);
}
}
@@ -758,55 +700,12 @@ class FilePage extends React.PureComponent {
{
showWebView: true,
},
() => {
pushDrawerStack(Constants.DRAWER_ROUTE_FILE_VIEW);
},
() => pushDrawerStack(Constants.DRAWER_ROUTE_FILE_VIEW)
);
}
}
};
handleWebViewLoad = () => {
const { contentType, fileInfo } = this.props;
const localFileUri = this.localUriForFileInfo(fileInfo);
if (this.webView && ['text/markdown', 'text/md'].includes(contentType)) {
RNFS.readFile(localFileUri, 'utf8').then(markdown => {
if (this.webView) {
if (!this.converter) {
this.converter = new showdown.Converter();
}
const html = this.converter.makeHtml(markdown);
this.webView.injectJavaScript(
'document.getElementById("content").innerHTML = \'' +
html.replace(/\n/g, '').replace(/'/g, "\\'") +
"'; true;",
);
}
});
}
};
buildWebViewSource = () => {
const { contentType, fileInfo } = this.props;
const localFileUri = this.localUriForFileInfo(fileInfo);
if (['text/markdown', 'text/md'].includes(contentType)) {
const html =
'<!doctype html>' +
'<html>' +
' <head>' +
' <meta charset="utf-8"/>' +
' </head>' +
' <body>' +
' <div id="content"></div>' +
' </body>' +
'</html>';
return { html };
}
return { uri: localFileUri };
};
render() {
const {
balance,
@@ -826,6 +725,8 @@ class FilePage extends React.PureComponent {
position,
purchaseUri,
pushDrawerStack,
isSearchingRecommendContent,
recommendedContent,
thumbnail,
title,
viewCount,
@@ -842,7 +743,7 @@ class FilePage extends React.PureComponent {
<View style={filePageStyle.pageContainer}>
<UriBar value={uri} navigation={navigation} />
{isResolvingUri && (
<View stylebuildWeb={filePageStyle.busyContainer}>
<View style={filePageStyle.busyContainer}>
<ActivityIndicator size="large" color={Colors.NextLbryGreen} />
<Text style={filePageStyle.infoText}>{__('Loading decentralized data...')}</Text>
</View>
@@ -893,7 +794,7 @@ class FilePage extends React.PureComponent {
<View style={filePageStyle.dmcaContainer}>
<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>
<Link style={filePageStyle.dmcaLink} href="https://lbry.com/faq/dmca" text={__('Read More')} />
@@ -953,9 +854,25 @@ class FilePage extends React.PureComponent {
const localFileUri = this.localUriForFileInfo(fileInfo);
const unsupported = !isPlayable && !canOpen;
if (
!this.state.autoDownloadStarted &&
claim &&
costInfo &&
((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) {
// automatically open a web viewable or image file after the download button is pressed
this.setState({ autoOpened: true }, () => this.openFile(localFileUri, mediaType, contentType));
this.setState({ autoOpened: true }, () => this.openFile(localFileUri, mediaType));
}
if (isChannel) {
@@ -965,19 +882,8 @@ class FilePage extends React.PureComponent {
return (
<View style={filePageStyle.pageContainer}>
{!this.state.fullscreenMode && <UriBar value={uri} navigation={navigation} />}
{innerContent}
{this.state.showWebView && isWebViewable && (
<WebView
ref={ref => {
this.webView = ref;
}}
allowFileAccess
javaScriptEnabled
originWhiteList={['*']}
source={this.buildWebViewSource()}
style={filePageStyle.viewer}
onLoad={this.handleWebViewLoad}
/>
<WebView allowFileAccess source={{ uri: localFileUri }} style={filePageStyle.viewer} />
)}
{this.state.showImageViewer && (
<ImageViewer
@@ -986,7 +892,7 @@ class FilePage extends React.PureComponent {
renderIndicator={() => null}
/>
)}
{!innerContent && !this.state.showWebView && (
{!this.state.showWebView && (
<View
style={
this.state.fullscreenMode ? filePageStyle.innerPageContainerFsMode : filePageStyle.innerPageContainer
@@ -1036,7 +942,7 @@ class FilePage extends React.PureComponent {
<FileDownloadButton
uri={claim && claim.permanent_url ? claim.permanent_url : uri}
style={filePageStyle.downloadButton}
openFile={() => this.openFile(localFileUri, mediaType, contentType)}
openFile={() => this.openFile(localFileUri, mediaType)}
isPlayable={isPlayable}
isViewable={isViewable}
onFileActionPress={this.onFileDownloadButtonPressed}
@@ -1044,19 +950,14 @@ class FilePage extends React.PureComponent {
/>
)}
{!fileInfo && (
<FilePrice
uri={claim && claim.permanent_url ? claim.permanent_url : uri}
style={filePageStyle.filePriceContainer}
textStyle={filePageStyle.filePriceText}
iconStyle={filePageStyle.filePriceIcon}
/>
<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)) && (
{(this.state.streamingMode || (canLoadMedia && fileInfo && isPlayable)) && (
<View
style={playerBgStyle}
ref={ref => {
@@ -1069,10 +970,10 @@ class FilePage extends React.PureComponent {
}}
/>
)}
{!innerContent &&
(this.state.streamingMode || (canLoadMedia && fileInfo && isPlayable)) &&
this.state.fullscreenMode && <View style={fsPlayerBgStyle} />}
{!innerContent && (this.state.streamingMode || (canLoadMedia && fileInfo && isPlayable)) && (
{(this.state.streamingMode || (canLoadMedia && fileInfo && isPlayable)) && this.state.fullscreenMode && (
<View style={fsPlayerBgStyle} />
)}
{(this.state.streamingMode || (canLoadMedia && fileInfo && isPlayable)) && (
<MediaPlayer
claim={claim}
assignPlayer={ref => {
@@ -1097,199 +998,195 @@ class FilePage extends React.PureComponent {
/>
)}
{!innerContent && (
<ScrollView
style={filePageStyle.scrollContainer}
contentContainerstyle={showActions ? null : filePageStyle.scrollContent}
keyboardShouldPersistTaps={'handled'}
ref={ref => {
this.scrollView = ref;
}}
<ScrollView
style={filePageStyle.scrollContainer}
contentContainerstyle={showActions ? null : filePageStyle.scrollContent}
keyboardShouldPersistTaps={'handled'}
ref={ref => {
this.scrollView = ref;
}}
>
<TouchableWithoutFeedback
style={filePageStyle.titleTouch}
onPress={() => this.setState({ showDescription: !this.state.showDescription })}
>
<TouchableWithoutFeedback
style={filePageStyle.titleTouch}
onPress={() => this.setState({ showDescription: !this.state.showDescription })}
>
<View style={filePageStyle.titleArea}>
<View style={filePageStyle.titleRow}>
<Text style={filePageStyle.title} selectable>
{title}
</Text>
{isRewardContent && <Icon name="award" style={filePageStyle.rewardIcon} size={16} />}
<View style={filePageStyle.descriptionToggle}>
<Icon name={this.state.showDescription ? 'caret-up' : 'caret-down'} size={24} />
</View>
</View>
<Text style={filePageStyle.viewCount}>
{viewCount === 1 && __('%view% view', { view: viewCount })}
{viewCount > 1 && __('%view% views', { view: viewCount })}
<View style={filePageStyle.titleArea}>
<View style={filePageStyle.titleRow}>
<Text style={filePageStyle.title} selectable>
{title}
</Text>
{isRewardContent && <Icon name="award" style={filePageStyle.rewardIcon} size={16} />}
<View style={filePageStyle.descriptionToggle}>
<Icon name={this.state.showDescription ? 'caret-up' : 'caret-down'} size={24} />
</View>
</View>
</TouchableWithoutFeedback>
<Text style={filePageStyle.viewCount}>
{viewCount === 1 && __('%view% view', { view: viewCount })}
{viewCount > 1 && __('%view% views', { view: viewCount })}
</Text>
</View>
</TouchableWithoutFeedback>
<View style={filePageStyle.largeButtonsRow}>
<TouchableOpacity style={filePageStyle.largeButton} onPress={this.handleSharePress}>
<Icon name={'share-alt'} size={16} style={filePageStyle.largeButtonIcon} />
<Text style={filePageStyle.largeButtonText}>{__('Share')}</Text>
</TouchableOpacity>
<View style={filePageStyle.largeButtonsRow}>
<TouchableOpacity style={filePageStyle.largeButton} onPress={this.handleSharePress}>
<Icon name={'share-alt'} size={16} style={filePageStyle.largeButtonIcon} />
<Text style={filePageStyle.largeButtonText}>{__('Share')}</Text>
</TouchableOpacity>
<TouchableOpacity
style={filePageStyle.largeButton}
onPress={() => this.setState({ showTipView: true })}
>
<Icon name={'gift'} size={16} style={filePageStyle.largeButtonIcon} />
<Text style={filePageStyle.largeButtonText}>{__('Tip')}</Text>
</TouchableOpacity>
<TouchableOpacity
style={filePageStyle.largeButton}
onPress={() => this.setState({ showTipView: true })}
>
<Icon name={'gift'} size={16} style={filePageStyle.largeButtonIcon} />
<Text style={filePageStyle.largeButtonText}>{__('Tip')}</Text>
</TouchableOpacity>
{!canEdit && !isPlayable && (
<View style={filePageStyle.sharedLargeButton}>
{(!fileInfo || (fileInfo.written_bytes <= 0 && !completed)) && (
{!canEdit && !isPlayable && (
<View style={filePageStyle.sharedLargeButton}>
{!fileInfo ||
(fileInfo.written_bytes <= 0 && !completed && (
<TouchableOpacity style={filePageStyle.innerLargeButton} onPress={this.onDownloadPressed}>
<Icon name={'download'} size={16} style={filePageStyle.largeButtonIcon} />
<Text style={filePageStyle.largeButtonText}>{__('Download')}</Text>
</TouchableOpacity>
)}
))}
{!completed &&
fileInfo &&
!fileInfo.stopped &&
fileInfo.written_bytes > 0 &&
fileInfo.written_bytes < fileInfo.total_bytes &&
!this.state.stopDownloadConfirmed && (
<TouchableOpacity style={filePageStyle.innerLargeButton} onPress={this.onStopDownloadPressed}>
<Icon name={'stop'} size={16} style={filePageStyle.largeButtonIcon} />
<Text style={filePageStyle.largeButtonText}>{__('Stop')}</Text>
</TouchableOpacity>
)}
{!completed &&
fileInfo &&
!fileInfo.stopped &&
fileInfo.written_bytes > 0 &&
fileInfo.written_bytes < fileInfo.total_bytes &&
!this.state.stopDownloadConfirmed && (
<TouchableOpacity style={filePageStyle.innerLargeButton} onPress={this.onStopDownloadPressed}>
<Icon name={'stop'} size={16} style={filePageStyle.largeButtonIcon} />
<Text style={filePageStyle.largeButtonText}>{__('Stop')}</Text>
</TouchableOpacity>
)}
{completed && fileInfo && (
<TouchableOpacity style={filePageStyle.innerLargeButton} onPress={this.onOpenFilePressed}>
<Icon name={'folder-open'} size={16} style={filePageStyle.largeButtonIcon} />
<Text style={filePageStyle.largeButtonText}>{__('Open')}</Text>
</TouchableOpacity>
)}
{completed && fileInfo && fileInfo.written_bytes >= fileInfo.total_bytes && (
<TouchableOpacity style={filePageStyle.innerLargeButton} onPress={this.onOpenFilePressed}>
<Icon name={'folder-open'} size={16} style={filePageStyle.largeButtonIcon} />
<Text style={filePageStyle.largeButtonText}>{__('Open')}</Text>
</TouchableOpacity>
)}
</View>
)}
{!canEdit && (
<TouchableOpacity
style={filePageStyle.largeButton}
onPress={() => Linking.openURL(`https://lbry.com/dmca/${claim.claim_id}`)}
>
<Icon name={'flag'} size={16} style={filePageStyle.largeButtonIcon} />
<Text style={filePageStyle.largeButtonText}>{__('Report')}</Text>
</TouchableOpacity>
)}
{canEdit && (
<TouchableOpacity style={filePageStyle.largeButton} onPress={this.onEditPressed}>
<Icon name={'edit'} size={16} style={filePageStyle.largeButtonIcon} />
<Text style={filePageStyle.largeButtonText}>{__('Edit')}</Text>
</TouchableOpacity>
)}
{(completed || canEdit) && (
<TouchableOpacity style={filePageStyle.largeButton} onPress={this.onDeletePressed}>
<Icon name={'trash-alt'} size={16} style={filePageStyle.largeButtonIcon} />
<Text style={filePageStyle.largeButtonText}>{__('Delete')}</Text>
</TouchableOpacity>
)}
</View>
<View style={filePageStyle.channelRow}>
<View style={filePageStyle.publishInfo}>
{channelName && (
<Link
style={filePageStyle.channelName}
selectable
text={channelName}
numberOfLines={1}
ellipsizeMode={'tail'}
onPress={() => {
navigateToUri(
navigation,
normalizeURI(shortChannelUri || fullChannelUri),
null,
false,
fullChannelUri
);
}}
/>
)}
{!channelName && (
<Text style={filePageStyle.anonChannelName} selectable ellipsizeMode={'tail'}>
{__('Anonymous')}
</Text>
)}
<DateTime
style={filePageStyle.publishDate}
textStyle={filePageStyle.publishDateText}
uri={uri}
formatOptions={{ day: 'numeric', month: 'long', year: 'numeric' }}
show={DateTime.SHOW_DATE}
/>
</View>
<View style={filePageStyle.subscriptionRow}>
{false && ((isPlayable && !fileInfo) || (isPlayable && fileInfo && !fileInfo.download_path)) && (
<Button
style={[filePageStyle.actionButton, filePageStyle.saveFileButton]}
theme={'light'}
icon={'download'}
onPress={this.onSaveFilePressed}
/>
)}
{channelName && (
<SubscribeButton
style={filePageStyle.actionButton}
uri={fullChannelUri}
name={channelName}
hideText={false}
/>
)}
{false && channelName && (
<SubscribeNotificationButton
style={[filePageStyle.actionButton, filePageStyle.bellButton]}
uri={fullChannelUri}
name={channelName}
/>
)}
</View>
</View>
{this.state.showDescription && description && description.length > 0 && (
<View style={filePageStyle.divider} />
)}
{this.state.showDescription && description && (
<View>
<Text style={filePageStyle.description} selectable>
{this.linkify(description)}
</Text>
{tags && tags.length > 0 && (
<View style={filePageStyle.tagContainer}>
<Text style={filePageStyle.tagTitle}>{__('Tags')}</Text>
<View style={filePageStyle.tagList}>{this.renderTags(tags)}</View>
</View>
)}
{!canEdit && (
<TouchableOpacity
style={filePageStyle.largeButton}
onPress={() => Linking.openURL(`https://lbry.com/dmca/${claim.claim_id}`)}
>
<Icon name={'flag'} size={16} style={filePageStyle.largeButtonIcon} />
<Text style={filePageStyle.largeButtonText}>{__('Report')}</Text>
</TouchableOpacity>
)}
{canEdit && (
<TouchableOpacity style={filePageStyle.largeButton} onPress={this.onEditPressed}>
<Icon name={'edit'} size={16} style={filePageStyle.largeButtonIcon} />
<Text style={filePageStyle.largeButtonText}>{__('Edit')}</Text>
</TouchableOpacity>
)}
{(completed || canEdit) && (
<TouchableOpacity style={filePageStyle.largeButton} onPress={this.onDeletePressed}>
<Icon name={'trash-alt'} size={16} style={filePageStyle.largeButtonIcon} />
<Text style={filePageStyle.largeButtonText}>{__('Delete')}</Text>
</TouchableOpacity>
)}
</View>
)}
<View style={filePageStyle.channelRow}>
<View style={filePageStyle.publishInfo}>
{channelName && (
<Link
style={filePageStyle.channelName}
selectable
text={channelName}
numberOfLines={1}
ellipsizeMode={'tail'}
onPress={() => {
navigateToUri(
navigation,
normalizeURI(shortChannelUri || fullChannelUri),
null,
false,
fullChannelUri,
);
}}
/>
)}
{!channelName && (
<Text style={filePageStyle.anonChannelName} selectable ellipsizeMode={'tail'}>
{__('Anonymous')}
</Text>
)}
<DateTime
style={filePageStyle.publishDate}
textStyle={filePageStyle.publishDateText}
uri={fullUri}
formatOptions={{ day: 'numeric', month: 'long', year: 'numeric' }}
show={DateTime.SHOW_DATE}
/>
</View>
<View style={filePageStyle.subscriptionRow}>
{false && ((isPlayable && !fileInfo) || (isPlayable && fileInfo && !fileInfo.download_path)) && (
<Button
style={[filePageStyle.actionButton, filePageStyle.saveFileButton]}
theme={'light'}
icon={'download'}
onPress={this.onSaveFilePressed}
/>
)}
{channelName && (
<SubscribeButton
style={filePageStyle.actionButton}
uri={fullChannelUri}
name={channelName}
hideText={false}
/>
)}
{false && channelName && (
<SubscribeNotificationButton
style={[filePageStyle.actionButton, filePageStyle.bellButton]}
uri={fullChannelUri}
name={channelName}
/>
)}
</View>
</View>
{costInfo && parseFloat(costInfo.cost) > balance && !fileInfo && (
<FileRewardsDriver navigation={navigation} />
)}
{this.state.showDescription && description && description.length > 0 && (
<View style={filePageStyle.divider} />
)}
{this.state.showDescription && description && (
<View>
<Text style={filePageStyle.description} selectable>
{this.linkify(description)}
</Text>
{tags && tags.length > 0 && (
<View style={filePageStyle.tagContainer}>
<Text style={filePageStyle.tagTitle}>{__('Tags')}</Text>
<View style={filePageStyle.tagList}>{this.renderTags(tags)}</View>
</View>
)}
</View>
)}
<View onLayout={this.setRelatedContentPosition} />
{costInfo && parseFloat(costInfo.cost) > balance && !fileInfo && (
<FileRewardsDriver navigation={navigation} />
)}
<View onLayout={this.setRelatedContentPosition} />
{this.state.showRecommended && (
<RelatedContent
navigation={navigation}
claimId={claim.claim_id}
title={title}
uri={fullUri}
fullUri={fullUri}
/>
)}
</ScrollView>
)}
{isSearchingRecommendContent && (
<ActivityIndicator size="small" color={Colors.NextLbryGreen} style={filePageStyle.relatedLoading} />
)}
{!isSearchingRecommendContent && recommendedContent && recommendedContent.length > 0 && (
<RelatedContent navigation={navigation} uri={uri} fullUri={fullUri} />
)}
</ScrollView>
</View>
)}
{this.state.showTipView && (
+18 -66
View File
@@ -16,7 +16,6 @@ import {
} from 'react-native';
import { FlatGrid } from 'react-native-super-grid';
import {
Lbry,
isNameValid,
batchActions,
buildURI,
@@ -161,8 +160,6 @@ class PublishPage extends React.PureComponent {
DeviceEventEmitter.removeListener('onAllGalleryThumbnailsChecked', this.handleAllGalleryThumbnailsChecked);
DeviceEventEmitter.removeListener('onDocumentPickerFilePicked', this.onFilePicked);
DeviceEventEmitter.removeListener('onDocumentPickerCanceled', this.onPickerCanceled);
DeviceEventEmitter.removeListener('onStoragePermissionGranted', this.handleStoragePermissionGranted);
DeviceEventEmitter.removeListener('onStoragePermissionRefused', this.handleStoragePermissionRefused);
}
handleGalleryThumbnailChecked = evt => {
@@ -185,27 +182,12 @@ class PublishPage extends React.PureComponent {
this.setState({ ...publishFormState, advancedMode });
};
checkStoragePermission = () => {
// 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();
}
});
};
onComponentFocused = () => {
const { balance, hasFormState, pushDrawerStack, setPlayerVisible, navigation } = this.props;
NativeModules.Firebase.setCurrentScreen('Publish').then(result => {
pushDrawerStack(Constants.DRAWER_ROUTE_PUBLISH, navigation.state.params ? navigation.state.params : null);
setPlayerVisible();
DeviceEventEmitter.addListener('onStoragePermissionGranted', this.handleStoragePermissionGranted);
DeviceEventEmitter.addListener('onStoragePermissionRefused', this.handleStoragePermissionRefused);
this.checkStoragePermission();
NativeModules.Gallery.canUseCamera().then(canUseCamera => this.setState({ canUseCamera }));
NativeModules.Gallery.getThumbnailPath().then(thumbnailPath => this.setState({ thumbnailPath }));
this.setState(
@@ -214,7 +196,7 @@ class PublishPage extends React.PureComponent {
},
() => {
NativeModules.Gallery.getVideos().then(videos => this.setState({ videos, loadingVideos: false }));
},
}
);
// Check if this is an edit action
@@ -306,7 +288,7 @@ class PublishPage extends React.PureComponent {
this.handleChannelChange(channelName);
}
pushDrawerStack(Constants.DRAWER_ROUTE_PUBLISH_FORM);
},
}
);
};
@@ -374,26 +356,18 @@ class PublishPage extends React.PureComponent {
}
if (!title || title.trim().length === 0) {
notify({ message: __('Please provide a title'), isError: true });
notify({ message: __('Please provide a title') });
return;
}
if (!name) {
notify({ message: __('Please specify an address where people can find your content.'), isError: true });
return;
}
if (!isNameValid(name, false)) {
notify({ message: __('Your content address contains invalid characters.'), isError: true });
notify({ message: __('Please specify an address where people can find your content.') });
return;
}
if (!currentMedia && !editMode) {
// sanity check. normally shouldn't happen
notify({
message: __('No file selected. Please select a video or take a photo before publishing.'),
isError: true,
});
notify({ message: __('No file selected. Please select a video or take a photo before publishing.') });
return;
}
@@ -482,7 +456,7 @@ class PublishPage extends React.PureComponent {
() => {
this.handleNameChange(this.state.name);
pushDrawerStack(Constants.DRAWER_ROUTE_PUBLISH_FORM);
},
}
);
}
@@ -536,7 +510,7 @@ class PublishPage extends React.PureComponent {
clearPublishFormState();
// reset thumbnail
updatePublishForm({ thumbnail: null });
},
}
);
}
@@ -563,7 +537,7 @@ class PublishPage extends React.PureComponent {
},
() => {
NativeModules.UtilityModule.openDocumentPicker('*/*');
},
}
);
};
@@ -609,7 +583,7 @@ class PublishPage extends React.PureComponent {
() => {
// upload a new thumbnail
uploadImageAsset(fileUrl, this.handleThumbnailUploadSuccess, this.handleThumbnailUploadFailure);
},
}
);
}
} else {
@@ -660,7 +634,7 @@ class PublishPage extends React.PureComponent {
videoRecordingMode: false,
recordingVideo: false,
},
() => pushDrawerStack(Constants.DRAWER_ROUTE_PUBLISH_FORM),
() => pushDrawerStack(Constants.DRAWER_ROUTE_PUBLISH_FORM)
);
});
}
@@ -684,7 +658,7 @@ class PublishPage extends React.PureComponent {
showCameraOverlay: false,
videoRecordingMode: false,
},
() => pushDrawerStack(Constants.DRAWER_ROUTE_PUBLISH),
() => pushDrawerStack(Constants.DRAWER_ROUTE_PUBLISH)
);
});
}
@@ -803,8 +777,8 @@ class PublishPage extends React.PureComponent {
uploadImageAsset(
this.getFilePathFromUri(uri),
this.handleThumbnailUploadSuccess,
this.handleThumbnailUploadFailure,
),
this.handleThumbnailUploadFailure
)
);
}
} else if (mediaType === 'image' || mediaType === 'video') {
@@ -817,7 +791,7 @@ class PublishPage extends React.PureComponent {
this.setState({ currentThumbnailUri: `file://${path}`, updatingThumbnailUri: false });
if (!this.state.uploadedThumbnailUri) {
this.setState({ uploadThumbnailStarted: true }, () =>
uploadImageAsset(path, this.handleThumbnailUploadSuccess, this.handleThumbnailUploadFailure),
uploadImageAsset(path, this.handleThumbnailUploadSuccess, this.handleThumbnailUploadFailure)
);
}
})
@@ -843,7 +817,7 @@ class PublishPage extends React.PureComponent {
},
() => {
this.handleNameChange(this.state.name);
},
}
);
}
};
@@ -907,32 +881,10 @@ class PublishPage extends React.PureComponent {
},
() => {
NativeModules.UtilityModule.openDocumentPicker('image/*');
},
}
);
};
handleStoragePermissionGranted = () => {
// update the configured download folder
NativeModules.UtilityModule.getDownloadDirectory().then(downloadDirectory => {
Lbry.settings_set({
key: 'download_dir',
value: downloadDirectory,
})
.then(() => {})
.catch(() => {});
});
};
handleStoragePermissionRefused = () => {
const { notify } = this.props;
notify({
message: __(
'Content from your device cannot be published because the permission to read storage was not granted.',
),
isError: true,
});
};
render() {
const { balance, navigation, notify, publishFormValues } = this.props;
const {
@@ -1160,7 +1112,7 @@ class PublishPage extends React.PureComponent {
{__('The address where people can find your content (ex. lbry://myvideo). ')}
{this.state.editMode &&
__(
'You cannot change this address while editing your content. If you wish to use a new address, please republish the content.',
'You cannot change this address while editing your content. If you wish to use a new address, please republish the content.'
)}
</Text>
@@ -1310,7 +1262,7 @@ class PublishPage extends React.PureComponent {
</View>
<Text style={publishStyle.successText}>
{__(
'Your content will be live in a few minutes. In the mean time, feel free to publish more content or explore the app.',
'Your content will be live in a few minutes. In the mean time, feel free to publish more content or explore the app.'
)}
</Text>
</View>
+8 -14
View File
@@ -1,46 +1,40 @@
import { connect } from 'react-redux';
import {
doClaimSearch,
doResolveUris,
doResolvedSearch,
doSearch,
doUpdateSearchQuery,
makeSelectResolvedSearchResults,
makeSelectResolvedSearchResultsLastPageReached,
makeSelectSearchUris,
selectClaimSearchByQuery,
selectIsSearching,
selectResolvingUris,
selectSearchValue,
makeSelectQueryWithOptions,
selectSearchUrisByQuery,
} from 'lbry-redux';
import { doPushDrawerStack, doSetPlayerVisible } from 'redux/actions/drawer';
import { selectCurrentRoute } from 'redux/selectors/drawer';
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
import SearchPage from './view';
const numSearchResults = 25;
const select = state => ({
claimSearchByQuery: selectClaimSearchByQuery(state),
currentRoute: selectCurrentRoute(state),
isSearching: selectIsSearching(state),
query: selectSearchValue(state),
resolvingUris: selectResolvingUris(state),
uris: makeSelectSearchUris(makeSelectQueryWithOptions(null, Constants.DEFAULT_PAGE_SIZE)(state))(state),
results: makeSelectResolvedSearchResults(makeSelectQueryWithOptions(null, Constants.DEFAULT_PAGE_SIZE)(state))(state),
lastPageReached: makeSelectResolvedSearchResultsLastPageReached(
makeSelectQueryWithOptions(null, Constants.DEFAULT_PAGE_SIZE)(state),
)(state),
uris: makeSelectSearchUris(makeSelectQueryWithOptions(null, numSearchResults)(state))(state),
urisByQuery: selectSearchUrisByQuery(state),
});
const perform = dispatch => ({
search: (query, from) => dispatch(doResolvedSearch(query, Constants.DEFAULT_PAGE_SIZE, from, false, {})),
search: query => dispatch(doSearch(query, numSearchResults)),
claimSearch: options => dispatch(doClaimSearch(options)),
updateSearchQuery: query => dispatch(doUpdateSearchQuery(query)),
pushDrawerStack: () => dispatch(doPushDrawerStack(Constants.DRAWER_ROUTE_SEARCH)),
resolveUris: uris => dispatch(doResolveUris(uris)),
setPlayerVisible: () => dispatch(doSetPlayerVisible(false)),
});
export default connect(
select,
perform,
perform
)(SearchPage);
+33 -96
View File
@@ -15,23 +15,17 @@ import Colors from 'styles/colors';
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
import PageHeader from 'component/pageHeader';
import FileListItem from 'component/fileListItem';
import FileResultItem from 'component/fileResultItem';
import FloatingWalletBalance from 'component/floatingWalletBalance';
import UriBar from 'component/uriBar';
import searchStyle from 'styles/search';
const softLimit = 500;
class SearchPage extends React.PureComponent {
state = {
currentQuery: null,
currentFrom: 0,
currentUri: null,
showTagResult: false,
claimSearchRun: false,
claimSearchOptions: null,
resultsResolved: false,
tagResultDisplayed: false,
};
static navigationOptions = {
@@ -59,16 +53,13 @@ class SearchPage extends React.PureComponent {
const searchQuery = query || this.getSearchQuery();
if (searchQuery && searchQuery.trim().length > 0) {
this.setState({
currentFrom: 0,
currentQuery: searchQuery,
currentUri: isURIValid(searchQuery) ? normalizeURI(searchQuery) : null,
claimSearchOptions: null,
claimSearchRun: false,
showTagResult: false,
resultsResolved: false,
tagResultDisplayed: false,
});
search(searchQuery, 0);
search(searchQuery);
}
});
};
@@ -78,8 +69,8 @@ class SearchPage extends React.PureComponent {
}
componentWillReceiveProps(nextProps) {
const { currentRoute, query, isSearching } = nextProps;
const { currentRoute: prevRoute, search, isSearching: prevIsSearching } = this.props;
const { currentRoute, query } = nextProps;
const { currentRoute: prevRoute, search } = this.props;
if (Constants.DRAWER_ROUTE_SEARCH === currentRoute && currentRoute !== prevRoute) {
this.onComponentFocused();
@@ -87,43 +78,10 @@ class SearchPage extends React.PureComponent {
if (query && query.trim().length > 0 && query !== this.state.currentQuery) {
this.setState({
currentFrom: 0,
currentQuery: query,
currentUri: isURIValid(query) ? normalizeURI(query) : null,
resultsResolved: false,
tagResultDisplayed: false,
});
search(query, 0);
}
}
allContentResolved(props) {
const { uris, resolvingUris } = 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(nextProps) {
const { isSearching, uris } = this.props;
return (isSearching && (!uris || uris.length === 0)) || (!isSearching && this.allContentResolved(this.props));
} */
componentDidUpdate() {
const { claimSearchByQuery } = this.props;
if (this.state.claimSearchRun && this.state.claimSearchOptions && !this.state.tagResultDisplayed) {
const claimSearchKey = createNormalizedClaimSearchKey(this.state.claimSearchOptions);
const claimSearchUris = claimSearchByQuery[claimSearchKey];
this.setState({ showTagResult: claimSearchUris && claimSearchUris.length > 0, tagResultDisplayed: true });
search(query);
}
}
@@ -139,15 +97,11 @@ class SearchPage extends React.PureComponent {
const { search } = this.props;
this.setState({
currentUri: isURIValid(keywords) ? normalizeURI(keywords) : null,
currentFrom: 0,
currentQuery: keywords,
claimSearchOptions: null,
claimSearchRun: false,
showTagResult: false,
resultsResolved: false,
tagResultDisplayed: false,
});
search(keywords, 0);
search(keywords);
};
listEmptyComponent = () => {
@@ -161,20 +115,27 @@ class SearchPage extends React.PureComponent {
);
};
listHeaderComponent = (showTagResult, query) => {
const { navigation, claimSearch } = this.props;
listHeaderComponent = showTagResult => {
const { navigation, claimSearch, claimSearchByQuery } = this.props;
const { currentUri } = this.state;
const query = this.getSearchQuery();
const canBeTag = query && query.trim().length > 0 && isURIValid(query);
if (canBeTag && !this.state.claimSearchRun) {
const options = {
any_tags: [query.toLowerCase()],
any_tags: [query],
page: 1,
no_totals: true,
};
this.setState({ claimSearchOptions: options, claimSearchRun: true }, () => claimSearch(options));
}
if (this.state.claimSearchRun && this.state.claimSearchOptions) {
const claimSearchKey = createNormalizedClaimSearchKey(this.state.claimSearchOptions);
const claimSearchUris = claimSearchByQuery[claimSearchKey];
this.setState({ showTagResult: claimSearchUris && claimSearchUris.length > 0 });
}
return (
<View>
<FileListItem uri={currentUri} featuredResult style={searchStyle.featuredResultItem} navigation={navigation} />
@@ -193,59 +154,35 @@ class SearchPage extends React.PureComponent {
navigation.navigate({ routeName: Constants.DRAWER_ROUTE_TAG, key: `tagPage`, params: { tag: tag.toLowerCase() } });
};
handleVerticalEndReached = () => {
// fetch more results
const { lastPageReached, results, search, isSearching } = this.props;
if (lastPageReached || (results && results.length > softLimit)) {
return;
}
if (!isSearching) {
const from = results ? results.length : 0;
this.setState({ currentFrom: from }, () => {
search(this.state.currentQuery, from);
});
}
};
render() {
const { isSearching, navigation, query, results } = this.props;
const { isSearching, navigation, query, uris, urisByQuery } = this.props;
return (
<View style={searchStyle.container}>
<UriBar value={query} navigation={navigation} onSearchSubmitted={this.handleSearchSubmitted} />
{isSearching && this.state.currentFrom === 0 && (
{isSearching && (
<View style={searchStyle.busyContainer}>
<ActivityIndicator size="large" color={Colors.NextLbryGreen} style={searchStyle.loading} />
</View>
)}
{(!isSearching || this.state.currentFrom > 0) && (
<FlatList
extraData={this.state}
style={searchStyle.scrollContainer}
contentContainerStyle={searchStyle.scrollPadding}
keyboardShouldPersistTaps={'handled'}
data={results}
keyExtractor={(item, index) => item.claimId}
initialNumToRender={10}
maxToRenderPerBatch={20}
onEndReached={this.handleVerticalEndReached}
onEndReachedThreshold={0.2}
removeClippedSubviews
ListEmptyComponent={!isSearching ? this.listEmptyComponent() : null}
ListHeaderComponent={this.listHeaderComponent(this.state.showTagResult, this.state.currentQuery)}
renderItem={({ item }) => (
<FileResultItem key={item.claimId} result={item} style={searchStyle.resultItem} navigation={navigation} />
)}
/>
)}
{this.state.currentFrom > 0 && isSearching && (
<View style={searchStyle.moreLoading}>
<ActivityIndicator size="small" color={Colors.NextLbryGreen} />
</View>
)}
<FlatList
extraData={this.state}
style={searchStyle.scrollContainer}
contentContainerStyle={searchStyle.scrollPadding}
keyboardShouldPersistTaps={'handled'}
data={uris}
keyExtractor={(item, index) => item}
initialNumToRender={10}
maxToRenderPerBatch={20}
removeClippedSubviews
ListEmptyComponent={!isSearching ? this.listEmptyComponent() : null}
ListHeaderComponent={this.state.currentUri ? this.listHeaderComponent(this.state.showTagResult) : null}
renderItem={({ item }) => (
<FileListItem key={item} uri={item} style={searchStyle.resultItem} navigation={navigation} />
)}
/>
<FloatingWalletBalance navigation={navigation} />
</View>
);
+36 -36
View File
@@ -94,9 +94,9 @@ class SplashScreen extends React.PureComponent {
NativeModules.UtilityModule.getSecureValue(Constants.KEY_WALLET_PASSWORD).then(walletPassword => {
getSync(walletPassword, () => {
this.getUserSettings();
this.navigateToMain();
});
});
this.navigateToMain();
return;
}
@@ -115,7 +115,7 @@ class SplashScreen extends React.PureComponent {
},
error => {
/* failed */
},
}
);
};
@@ -137,32 +137,32 @@ class SplashScreen extends React.PureComponent {
user,
} = this.props;
// Lbry.resolve({ urls: 'lbry://one' }).then(() => {
// Leave the splash screen
balanceSubscribe();
blacklistedOutpointsSubscribe();
filteredOutpointsSubscribe();
checkSubscriptionsInit();
Lbry.resolve({ urls: 'lbry://one' }).then(() => {
// Leave the splash screen
balanceSubscribe();
blacklistedOutpointsSubscribe();
filteredOutpointsSubscribe();
checkSubscriptionsInit();
if (user && user.id && user.has_verified_email) {
// user already authenticated
NativeModules.UtilityModule.getSecureValue(Constants.KEY_WALLET_PASSWORD).then(walletPassword => {
getSync(walletPassword, () => {
this.getUserSettings();
if (user && user.id && user.has_verified_email) {
// user already authenticated
NativeModules.UtilityModule.getSecureValue(Constants.KEY_WALLET_PASSWORD).then(walletPassword => {
getSync(walletPassword, () => {
this.getUserSettings();
this.navigateToMain();
});
});
});
this.navigateToMain();
} else {
NativeModules.VersionInfo.getAppVersion().then(appVersion => {
this.setState({ shouldAuthenticate: true });
NativeModules.Firebase.getMessagingToken()
.then(firebaseToken => {
authenticate(appVersion, Platform.OS, firebaseToken);
})
.catch(() => authenticate(appVersion, Platform.OS));
});
}
// });
} else {
NativeModules.VersionInfo.getAppVersion().then(appVersion => {
this.setState({ shouldAuthenticate: true });
NativeModules.Firebase.getMessagingToken()
.then(firebaseToken => {
authenticate(appVersion, Platform.OS, firebaseToken);
})
.catch(() => authenticate(appVersion, Platform.OS));
});
}
});
};
handleAccountUnlockFailed() {
@@ -200,8 +200,8 @@ class SplashScreen extends React.PureComponent {
Lbry.wallet_unlock({ password: password || '' }).then(unlocked => {
if (unlocked) {
this.setState({
message: __('Authenticating'),
details: __('Waiting for authentication'),
message: __('Testing network'),
details: __('Waiting for name resolution'),
});
this.finishSplashScreen();
} else {
@@ -210,8 +210,8 @@ class SplashScreen extends React.PureComponent {
});
} else {
this.setState({
message: __('Authenticating'),
details: __('Waiting for authentication'),
message: __('Testing network'),
details: __('Waiting for name resolution'),
});
this.finishSplashScreen();
}
@@ -293,7 +293,7 @@ class SplashScreen extends React.PureComponent {
isLagging: true,
message: __('Connection Failure'),
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.'
),
});
});
@@ -315,10 +315,10 @@ class SplashScreen extends React.PureComponent {
this.setState(
{
accountUnlockFailed: false,
message: __('Authenticating'),
details: __('Waiting for authentication'),
message: __('Testing network'),
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.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 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>
+2 -5
View File
@@ -73,7 +73,7 @@ class SubscriptionsPage extends React.PureComponent {
};
componentDidMount() {
// this.onComponentFocused();
this.onComponentFocused();
}
componentWillReceiveProps(nextProps) {
@@ -115,10 +115,7 @@ class SubscriptionsPage extends React.PureComponent {
unsubscribeShortChannelUrls = () => {
// this should only have to happen once
const { subscribedChannels, channelUnsubscribe } = this.props;
const badSubs = subscribedChannels.filter(sub => {
const parts = sub.uri.split('#');
return parts.length === 1 || parts[1].length < 5;
});
const badSubs = subscribedChannels.filter(sub => sub.uri.split('#')[1].length < 5);
if (badSubs.length > 0) {
badSubs.forEach(sub => channelUnsubscribe(sub));
}
@@ -34,7 +34,6 @@ class PhoneVerifyPage extends React.PureComponent {
codeVerifyStarted: false,
codeVerifySuccessful: false,
countryCode: null,
countryPickerVisible: false,
newPhoneAdded: false,
number: null,
phoneVerifyFailed: false,
@@ -126,15 +125,15 @@ class PhoneVerifyPage extends React.PureComponent {
};
onPressFlag = () => {
this.setState({ countryPickerVisible: true });
if (this.picker) {
this.picker.openModal();
}
};
selectCountry = country => {
selectCountry(country) {
this.phoneInput.selectCountry(country.cca2.toLowerCase());
this.setState({ cca2: country.cca2, countryPickerVisible: false }, () => {
this.phoneInput.focus();
});
};
this.setState({ cca2: country.cca2 });
}
handleChangeText = text => {
this.setState({ verificationCode: text });
@@ -234,17 +233,17 @@ class PhoneVerifyPage extends React.PureComponent {
</View>
<CountryPicker
countryCode={this.state.cca2}
withAlphaFilter
withFilter
withFlag
withFlagButton={false}
withCallingCode
withModal
onSelect={this.selectCountry}
ref={picker => {
this.picker = picker;
}}
cca2={this.state.cca2}
filterable
onChange={value => this.selectCountry(value)}
showCallingCode
translation="eng"
modalProps={{ visible: this.state.countryPickerVisible }}
/>
>
<View />
</CountryPicker>
</View>
);
}
-6
View File
@@ -166,8 +166,6 @@ const discoverStyle = StyleSheet.create({
filePriceContainer: {
backgroundColor: Colors.NextLbryGreen,
justifyContent: 'center',
alignItems: 'center',
flexDirection: 'row',
position: 'absolute',
right: 8,
top: 8,
@@ -181,10 +179,6 @@ const discoverStyle = StyleSheet.create({
textAlign: 'center',
color: '#0c604b',
},
filePriceIcon: {
marginRight: 2,
color: '#0c604b',
},
rightHeaderIcon: {
marginRight: 16,
},
+1
View File
@@ -24,6 +24,7 @@ const downloadsStyle = StyleSheet.create({
paddingLeft: 16,
paddingRight: 16,
marginTop: 16,
marginBottom: 60,
},
scrollPadding: {
marginTop: -16,
-22
View File
@@ -120,28 +120,6 @@ const fileListStyle = StyleSheet.create({
marginLeft: 4,
marginTop: 4,
},
filePriceContainer: {
backgroundColor: Colors.NextLbryGreen,
justifyContent: 'center',
alignItems: 'center',
flexDirection: 'row',
position: 'absolute',
left: thumbnailWidth - 60,
top: 4,
width: 56,
height: 24,
borderRadius: 4,
},
filePriceText: {
fontFamily: 'Inter-UI-Bold',
fontSize: 12,
textAlign: 'center',
color: '#0c604b',
},
filePriceIcon: {
marginRight: 2,
color: '#0c604b',
},
});
export default fileListStyle;
-5
View File
@@ -170,8 +170,6 @@ const filePageStyle = StyleSheet.create({
filePriceContainer: {
backgroundColor: Colors.NextLbryGreen,
justifyContent: 'center',
alignItems: 'center',
flexDirection: 'row',
position: 'absolute',
right: 16,
top: 16,
@@ -185,9 +183,6 @@ const filePageStyle = StyleSheet.create({
textAlign: 'center',
color: '#0c604b',
},
filePriceIcon: {
marginRight: 2,
},
actions: {
flexDirection: 'row',
justifyContent: 'space-between',
-6
View File
@@ -80,12 +80,6 @@ const searchStyle = StyleSheet.create({
loading: {
position: 'absolute',
},
moreLoading: {
width: '100%',
height: 48,
alignItems: 'center',
justifyContent: 'center',
},
});
export default searchStyle;
-1
View File
@@ -31,7 +31,6 @@ const uriBarStyle = StyleSheet.create({
paddingRight: 12,
fontFamily: 'Inter-UI-Regular',
fontSize: 16,
height: 44,
lineHeight: 18,
flex: 17,
},
+2 -7
View File
@@ -27,16 +27,11 @@ const walletStyle = StyleSheet.create({
},
address: {
fontFamily: 'Inter-UI-Regular',
letterSpacing: 0.8,
borderWidth: 1,
borderRadius: 16,
borderStyle: 'dashed',
borderColor: '#e1e1e1',
borderColor: '#cccccc',
backgroundColor: '#f9f9f9',
paddingTop: 8,
paddingLeft: 8,
paddingRight: 8,
paddingBottom: 6,
padding: 8,
width: '85%',
},
button: {