Compare commits

..
28 changed files with 511 additions and 168 deletions

No files matched your search

+2 -2
View File
@@ -7047,8 +7047,8 @@
}
},
"lbry-redux": {
"version": "github:lbryio/lbry-redux#2c569a729bb40d45249ca38150b00922162b7ce3",
"from": "github:lbryio/lbry-redux#2c569a729bb40d45249ca38150b00922162b7ce3",
"version": "github:lbryio/lbry-redux#e8f29f1c47b136669df265babb109d2488a37db0",
"from": "github:lbryio/lbry-redux#e8f29f1c47b136669df265babb109d2488a37db0",
"requires": {
"proxy-polyfill": "0.1.6",
"reselect": "^3.0.0",
+1 -1
View File
@@ -12,7 +12,7 @@
"base-64": "^0.1.0",
"@expo/vector-icons": "^8.1.0",
"gfycat-style-urls": "^1.0.3",
"lbry-redux": "lbryio/lbry-redux#2c569a729bb40d45249ca38150b00922162b7ce3",
"lbry-redux": "lbryio/lbry-redux#e8f29f1c47b136669df265babb109d2488a37db0",
"lbryinc": "lbryio/lbryinc#053ca52f4f7f9bf8eb62a3581b183671a475ad1c",
"lodash": ">=4.17.11",
"merge": ">=1.2.1",
+7 -3
View File
@@ -1,8 +1,12 @@
import AsyncStorage from '@react-native-community/async-storage';
import Reactotron from 'reactotron-react-native'
import Reactotron from 'reactotron-react-native';
import { reactotronRedux } from 'reactotron-redux';
Reactotron
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
.connect(); // let's connect!
.use(reactotronRedux())
.connect();
export default reactotron;
+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: 'Subscriptions', route: Constants.DRAWER_ROUTE_SUBSCRIPTIONS },
{ icon: 'heart', solid: true, label: 'Following', route: Constants.DRAWER_ROUTE_SUBSCRIPTIONS },
{ icon: 'globe-americas', label: 'All Content', route: Constants.DRAWER_ROUTE_TRENDING },
],
'Your content': [
-1
View File
@@ -30,7 +30,6 @@ class FileDownloadButton extends React.PureComponent {
fileInfo,
downloading,
uri,
purchaseUri,
costInfo,
isPlayable,
isViewable,
+7 -2
View File
@@ -107,7 +107,12 @@ 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} textStyle={discoverStyle.filePriceText} />
<FilePrice
uri={uri}
style={discoverStyle.filePriceContainer}
iconStyle={discoverStyle.filePriceIcon}
textStyle={discoverStyle.filePriceText}
/>
)}
{!compactView && (
<View style={isRewardContent ? discoverStyle.rewardTitleContainer : null}>
@@ -129,7 +134,7 @@ class FileItem extends React.PureComponent {
normalizeURI(shortChannelUri || fullChannelUri),
null,
false,
fullChannelUri
fullChannelUri,
);
}}
/>
+3 -2
View File
@@ -61,6 +61,7 @@ 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) {
@@ -75,7 +76,7 @@ class FileItemMedia extends React.PureComponent {
resizeMode={this.getFastImageResizeMode(resizeMode)}
style={fileItemMediaStyle.image}
/>
{duration && (
{duration > 0 && (
<VideoDuration
duration={duration}
style={fileItemMediaStyle.duration}
@@ -104,7 +105,7 @@ class FileItemMedia extends React.PureComponent {
.toUpperCase()}
</Text>
)}
{duration && (
{duration > 0 && (
<VideoDuration
duration={duration}
style={fileItemMediaStyle.duration}
+1 -1
View File
@@ -36,5 +36,5 @@ const perform = dispatch => ({
export default connect(
select,
perform
perform,
)(FileListItem);
+7 -2
View File
@@ -6,6 +6,7 @@ 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';
@@ -42,7 +43,6 @@ class FileListItem extends React.PureComponent {
componentDidMount() {
const { claim, resolveUri, uri, batchResolve } = this.props;
if (!claim && !batchResolve) {
console.log('resolving on componentDidMount?');
resolveUri(uri);
}
}
@@ -50,7 +50,6 @@ class FileListItem extends React.PureComponent {
componentDidUpdate() {
const { claim, resolveUri, uri, batchResolve } = this.props;
if (!claim && uri !== this.state.url && !batchResolve) {
console.log('resolving on componentDidUpdate?');
this.setState({ url: uri }, () => resolveUri(uri));
}
}
@@ -168,6 +167,12 @@ 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}>
+21 -23
View File
@@ -2,6 +2,7 @@ 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 = {
@@ -62,25 +63,27 @@ class CreditAmount extends React.PureComponent {
}
}
/* {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>;
return (
<Text style={style} numberOfLines={1}>
{amountText}
</Text>
);
}
}
class FilePrice extends React.PureComponent {
componentWillMount() {
this.fetchCost(this.props);
const { cost } = this.props;
if (isNaN(parseFloat(cost))) {
this.fetchCost(this.props);
}
}
componentWillReceiveProps(nextProps) {
this.fetchCost(nextProps);
const { cost } = this.props;
if (isNaN(parseFloat(cost))) {
this.fetchCost(nextProps);
}
}
fetchCost(props) {
@@ -92,30 +95,25 @@ class FilePrice extends React.PureComponent {
}
render() {
const { costInfo, look = 'indicator', showFullPrice = false, style, textStyle } = this.props;
const { cost, costInfo, look = 'indicator', showFullPrice = false, style, iconStyle, textStyle } = this.props;
const isEstimate = costInfo ? !costInfo.includesData : null;
if (!costInfo) {
return (
<View style={style}>
<Text style={textStyle}>???</Text>
</View>
);
const amount = cost ? parseFloat(cost) : costInfo ? parseFloat(costInfo.cost) : 0;
if (isNaN(amount) || amount === 0) {
return null;
}
return (
<View style={style}>
<Icon name="coins" size={9} style={iconStyle} />
<CreditAmount
style={textStyle}
label={false}
amount={parseFloat(costInfo.cost)}
amount={amount}
isEstimate={isEstimate}
showFree
showFullPrice={showFullPrice}
>
???
</CreditAmount>
/>
</View>
);
}
+40
View File
@@ -0,0 +1,40 @@
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
@@ -0,0 +1,146 @@
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;
+7 -4
View File
@@ -1,24 +1,27 @@
import { connect } from 'react-redux';
import {
doResolveUris,
doSearch,
doResolvedSearch,
makeSelectClaimForUri,
makeSelectRecommendedContentForUri,
makeSelectResolvedRecommendedContentForUri,
selectResolvingUris,
selectIsSearching,
} from 'lbry-redux';
import RelatedContent from './view';
const RESULT_SIZE = 16;
const select = (state, props) => ({
claim: makeSelectClaimForUri(props.uri)(state),
isSearching: selectIsSearching(state),
recommendedContent: makeSelectRecommendedContentForUri(props.uri)(state),
recommendedContent: makeSelectResolvedRecommendedContentForUri(props.uri, RESULT_SIZE)(state),
resolvingUris: selectResolvingUris(state),
});
const perform = dispatch => ({
resolveUris: uris => dispatch(doResolveUris(uris)),
searchRecommended: query => dispatch(doSearch(query, 20, undefined, true, false)),
searchRecommended: (query, claimId) =>
dispatch(doResolvedSearch(query, RESULT_SIZE, undefined, true, { related_to: claimId }, false)),
});
export default connect(
+14 -45
View File
@@ -4,49 +4,21 @@ 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 {
state = {
resolveStarted: false,
};
componentDidMount() {
const { title, searchRecommended } = this.props;
if (title) {
searchRecommended(title);
const { title, claimId, searchRecommended } = this.props;
if (title && claimId) {
searchRecommended(title, claimId);
}
}
shouldComponentUpdate(nextProps, nextState) {
const { isSearching, recommendedContent } = nextProps;
return isSearching || (!isSearching && this.allContentResolved());
}
allContentResolved() {
const { recommendedContent, resolvingUris } = this.props;
if (recommendedContent) {
let allResolved = true;
recommendedContent.forEach(uri => {
allResolved = allResolved && !resolvingUris.includes(uri);
});
return allResolved;
}
return false;
}
componentDidUpdate() {
const { 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);
}
});
}
return isSearching || (!isSearching && recommendedContent && recommendedContent.length > 0);
}
render() {
@@ -57,18 +29,15 @@ export default class RelatedContent extends React.PureComponent {
<Text style={relatedContentStyle.title}>{__('Related Content')}</Text>
{isSearching && <ActivityIndicator size={'small'} color={Colors.NextLbryGreen} />}
{recommendedContent &&
recommendedContent
.filter(recommendedUri => recommendedUri !== normalizeURI(fullUri))
.map(recommendedUri => (
<FileListItem
style={fileListStyle.item}
key={recommendedUri}
uri={recommendedUri}
batchResolve
navigation={navigation}
autoplay
/>
))}
recommendedContent.map(result => (
<FileResultItem
style={fileListStyle.item}
key={result.claimId}
result={result}
navigation={navigation}
autoplay
/>
))}
</View>
);
}
+6 -3
View File
@@ -85,7 +85,7 @@ class UriBar extends React.PureComponent {
Keyboard.dismiss();
if (SEARCH_TYPES.SEARCH === type) {
this.setState({ currentValue: value });
this.setState({ currentValue: value }, () => this.setCaretPosition(value));
updateSearchQuery(value);
if (onSearchSubmitted) {
@@ -124,7 +124,7 @@ class UriBar extends React.PureComponent {
};
setSelection() {
if (this.textInput) {
if (this.textInput && !this.state.focused) {
this.textInput.setNativeProps({ selection: { start: 0, end: 0 } });
}
}
@@ -253,7 +253,9 @@ class UriBar extends React.PureComponent {
autoCorrect={false}
style={uriBarStyle.uriText}
onLayout={() => {
this.setSelection();
if (!this.state.focused) {
this.setSelection();
}
}}
selectTextOnFocus
placeholder={__('Search movies, music, and more')}
@@ -270,6 +272,7 @@ class UriBar extends React.PureComponent {
this.setSelection();
}}
onChangeText={this.handleChangeText}
onChange={this.handleChange}
onSubmitEditing={this.handleSubmitEditing}
/>
)}
+6 -2
View File
@@ -38,9 +38,10 @@ class WalletSend extends React.PureComponent<Props> {
handleSend = () => {
const { balance, sendToAddress, notify } = this.props;
const { address, amount } = this.state;
if (address && !regexAddress.test(address)) {
if (address && (!regexAddress.test(address) || address.substring(0, 1) === 'r')) {
notify({
message: __('The recipient address is not a valid LBRY address.'),
isError: true,
});
return;
}
@@ -48,6 +49,7 @@ class WalletSend extends React.PureComponent<Props> {
if (amount > balance) {
notify({
message: __('Insufficient credits'),
isError: true,
});
return;
}
@@ -72,6 +74,7 @@ class WalletSend extends React.PureComponent<Props> {
const { notify } = this.props;
notify({
message: __('The recipient address is not a valid LBRY address.'),
isError: true,
});
}
};
@@ -97,9 +100,10 @@ class WalletSend extends React.PureComponent<Props> {
this.setState({
address: value,
addressChanged: true,
addressValid: value.trim().length === 0 || regexAddress.test(value),
addressValid: value.trim().length === 0 || (regexAddress.test(value) && !value.startsWith('r')),
})
}
numberOfLines={1}
onBlur={this.handleAddressInputBlur}
onSubmitEditing={this.handleAddressInputSubmit}
placeholder={'bbFxRyXXXXXXXXXXXZD8nE7XTLUxYnddTs'}
+3 -2
View File
@@ -42,6 +42,7 @@ 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';
@@ -179,7 +180,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)),
);
}
};
@@ -195,7 +196,7 @@ const composeEnhancers = compose;
const store = createStore(
enableBatching(reducers),
{}, // initial state,
composeEnhancers(applyMiddleware(...middleware))
composeEnhancers(applyMiddleware(...middleware), reactotron.createEnhancer()),
);
window.store = store;
+44 -8
View File
@@ -1,5 +1,5 @@
import React from 'react';
import { CLAIM_VALUES, formatCredits, isNameValid, regexInvalidURI } from 'lbry-redux';
import { CLAIM_VALUES, Lbry, 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,
},
() => NativeModules.UtilityModule.openDocumentPicker('image/*')
() => this.checkStoragePermission(),
);
};
@@ -543,7 +543,7 @@ export default class ChannelCreator extends React.PureComponent {
avatarImagePickerOpen: true,
coverImagePickerOpen: false,
},
() => NativeModules.UtilityModule.openDocumentPicker('image/*')
() => this.checkStoragePermission(),
);
};
@@ -673,7 +673,7 @@ export default class ChannelCreator extends React.PureComponent {
},
},
],
{ cancelable: true }
{ cancelable: true },
);
};
@@ -749,6 +749,42 @@ 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 {
+65 -28
View File
@@ -113,8 +113,8 @@ class FilePage extends React.PureComponent {
if (!isResolvingUri && !claim) resolveUri(uri);
this.fetchFileInfo(this.props);
this.fetchCostInfo(this.props);
this.fetchFileInfo(uri, this.props);
this.fetchCostInfo(uri, this.props);
fetchMyClaims();
@@ -148,7 +148,6 @@ class FilePage extends React.PureComponent {
navigation,
contentType,
notify,
recommendedContent: prevRecommendedContent,
drawerStack: prevDrawerStack,
} = this.props;
const { uri } = navigation.state.params;
@@ -160,7 +159,6 @@ class FilePage extends React.PureComponent {
purchaseUriErrorMessage,
streamingUrl,
drawerStack,
recommendedContent,
resolveUris,
} = nextProps;
@@ -214,13 +212,6 @@ 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) {
@@ -259,21 +250,26 @@ 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());
}
}
fetchFileInfo(props) {
if (props.fileInfo === undefined) {
props.fetchFileInfo(props.navigation.state.params.uri);
if (((costInfo && costInfo.cost > 0) || !isPlayable) && !this.state.showRecommended) {
this.setState({ showRecommended: true });
}
}
fetchCostInfo(props) {
fetchFileInfo(uri, props) {
if (props.fileInfo === undefined) {
props.fetchFileInfo(uri);
}
}
fetchCostInfo(uri, props) {
if (props.costInfo === undefined) {
props.fetchCostInfo(props.navigation.state.params.uri);
props.fetchCostInfo(uri);
}
}
@@ -308,12 +304,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;
@@ -598,6 +594,38 @@ 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);
@@ -610,7 +638,7 @@ class FilePage extends React.PureComponent {
if (!isPlayable) {
this.checkStoragePermissionForDownload();
} else {
purchaseUri(uri, costInfo, !isPlayable);
this.confirmPurchaseUri(uri, costInfo, !isPlayable);
}
if (isPlayable) {
@@ -648,7 +676,7 @@ class FilePage extends React.PureComponent {
stopDownloadConfirmed: false,
},
() => {
purchaseUri(claim.permanent_url, costInfo, true);
this.confirmPurchaseUri(claim.permanent_url, costInfo, true);
NativeModules.UtilityModule.checkDownloads();
},
);
@@ -723,8 +751,6 @@ class FilePage extends React.PureComponent {
position,
purchaseUri,
pushDrawerStack,
isSearchingRecommendContent,
recommendedContent,
thumbnail,
title,
viewCount,
@@ -862,7 +888,7 @@ class FilePage extends React.PureComponent {
if (!isPlayable) {
this.checkStoragePermissionForDownload();
} else {
purchaseUri(claim.permanent_url, costInfo, !isPlayable);
this.confirmPurchaseUri(claim.permanent_url, costInfo, !isPlayable);
}
NativeModules.UtilityModule.checkDownloads();
});
@@ -950,7 +976,12 @@ class FilePage extends React.PureComponent {
/>
)}
{!fileInfo && (
<FilePrice uri={uri} style={filePageStyle.filePriceContainer} textStyle={filePageStyle.filePriceText} />
<FilePrice
uri={claim && claim.permanent_url ? claim.permanent_url : uri}
style={filePageStyle.filePriceContainer}
textStyle={filePageStyle.filePriceText}
iconStyle={filePageStyle.filePriceIcon}
/>
)}
<TouchableOpacity style={filePageStyle.backButton} onPress={this.onBackButtonPressed}>
@@ -1182,7 +1213,13 @@ class FilePage extends React.PureComponent {
<View onLayout={this.setRelatedContentPosition} />
{this.state.showRecommended && (
<RelatedContent navigation={navigation} title={title} uri={fullUri} fullUri={fullUri} />
<RelatedContent
navigation={navigation}
claimId={claim.claim_id}
title={title}
uri={fullUri}
fullUri={fullUri}
/>
)}
</ScrollView>
)}
+66 -18
View File
@@ -16,6 +16,7 @@ import {
} from 'react-native';
import { FlatGrid } from 'react-native-super-grid';
import {
Lbry,
isNameValid,
batchActions,
buildURI,
@@ -160,6 +161,8 @@ 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 => {
@@ -182,12 +185,27 @@ 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(
@@ -196,7 +214,7 @@ class PublishPage extends React.PureComponent {
},
() => {
NativeModules.Gallery.getVideos().then(videos => this.setState({ videos, loadingVideos: false }));
}
},
);
// Check if this is an edit action
@@ -288,7 +306,7 @@ class PublishPage extends React.PureComponent {
this.handleChannelChange(channelName);
}
pushDrawerStack(Constants.DRAWER_ROUTE_PUBLISH_FORM);
}
},
);
};
@@ -356,18 +374,26 @@ class PublishPage extends React.PureComponent {
}
if (!title || title.trim().length === 0) {
notify({ message: __('Please provide a title') });
notify({ message: __('Please provide a title'), isError: true });
return;
}
if (!name) {
notify({ message: __('Please specify an address where people can find your content.') });
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 });
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.') });
notify({
message: __('No file selected. Please select a video or take a photo before publishing.'),
isError: true,
});
return;
}
@@ -456,7 +482,7 @@ class PublishPage extends React.PureComponent {
() => {
this.handleNameChange(this.state.name);
pushDrawerStack(Constants.DRAWER_ROUTE_PUBLISH_FORM);
}
},
);
}
@@ -510,7 +536,7 @@ class PublishPage extends React.PureComponent {
clearPublishFormState();
// reset thumbnail
updatePublishForm({ thumbnail: null });
}
},
);
}
@@ -537,7 +563,7 @@ class PublishPage extends React.PureComponent {
},
() => {
NativeModules.UtilityModule.openDocumentPicker('*/*');
}
},
);
};
@@ -583,7 +609,7 @@ class PublishPage extends React.PureComponent {
() => {
// upload a new thumbnail
uploadImageAsset(fileUrl, this.handleThumbnailUploadSuccess, this.handleThumbnailUploadFailure);
}
},
);
}
} else {
@@ -634,7 +660,7 @@ class PublishPage extends React.PureComponent {
videoRecordingMode: false,
recordingVideo: false,
},
() => pushDrawerStack(Constants.DRAWER_ROUTE_PUBLISH_FORM)
() => pushDrawerStack(Constants.DRAWER_ROUTE_PUBLISH_FORM),
);
});
}
@@ -658,7 +684,7 @@ class PublishPage extends React.PureComponent {
showCameraOverlay: false,
videoRecordingMode: false,
},
() => pushDrawerStack(Constants.DRAWER_ROUTE_PUBLISH)
() => pushDrawerStack(Constants.DRAWER_ROUTE_PUBLISH),
);
});
}
@@ -777,8 +803,8 @@ class PublishPage extends React.PureComponent {
uploadImageAsset(
this.getFilePathFromUri(uri),
this.handleThumbnailUploadSuccess,
this.handleThumbnailUploadFailure
)
this.handleThumbnailUploadFailure,
),
);
}
} else if (mediaType === 'image' || mediaType === 'video') {
@@ -791,7 +817,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),
);
}
})
@@ -817,7 +843,7 @@ class PublishPage extends React.PureComponent {
},
() => {
this.handleNameChange(this.state.name);
}
},
);
}
};
@@ -881,10 +907,32 @@ 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 {
@@ -1112,7 +1160,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>
@@ -1262,7 +1310,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>
+4 -2
View File
@@ -2,8 +2,9 @@ import { connect } from 'react-redux';
import {
doClaimSearch,
doResolveUris,
doSearch,
doResolvedSearch,
doUpdateSearchQuery,
makeSelectResolvedSearchResults,
makeSelectSearchUris,
selectClaimSearchByQuery,
selectIsSearching,
@@ -25,10 +26,11 @@ const select = state => ({
query: selectSearchValue(state),
resolvingUris: selectResolvingUris(state),
uris: makeSelectSearchUris(makeSelectQueryWithOptions(null, numSearchResults)(state))(state),
results: makeSelectResolvedSearchResults(makeSelectQueryWithOptions(null, numSearchResults)(state))(state),
});
const perform = dispatch => ({
search: query => dispatch(doSearch(query, numSearchResults, null, false, false)),
search: query => dispatch(doResolvedSearch(query, numSearchResults, null, false, {})),
claimSearch: options => dispatch(doClaimSearch(options)),
updateSearchQuery: query => dispatch(doUpdateSearchQuery(query)),
pushDrawerStack: () => dispatch(doPushDrawerStack(Constants.DRAWER_ROUTE_SEARCH)),
+15 -13
View File
@@ -15,6 +15,7 @@ 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';
@@ -71,8 +72,8 @@ class SearchPage extends React.PureComponent {
}
componentWillReceiveProps(nextProps) {
const { currentRoute, query } = nextProps;
const { currentRoute: prevRoute, search } = this.props;
const { currentRoute, query, isSearching } = nextProps;
const { currentRoute: prevRoute, search, isSearching: prevIsSearching } = this.props;
if (Constants.DRAWER_ROUTE_SEARCH === currentRoute && currentRoute !== prevRoute) {
this.onComponentFocused();
@@ -88,8 +89,8 @@ class SearchPage extends React.PureComponent {
}
}
allContentResolved() {
const { uris, resolvingUris } = this.props;
allContentResolved(props) {
const { uris, resolvingUris } = props;
if (!this.state.resultsResolved) {
return false;
}
@@ -104,20 +105,20 @@ class SearchPage extends React.PureComponent {
return false;
}
shouldComponentUpdate() {
/* shouldComponentUpdate(nextProps) {
const { isSearching, uris } = this.props;
return (isSearching && (!uris || uris.length === 0)) || (!isSearching && this.allContentResolved());
}
return (isSearching && (!uris || uris.length === 0)) || (!isSearching && this.allContentResolved(this.props));
} */
componentDidUpdate() {
const { isSearching, resolveUris, uris } = this.props;
/* const { isSearching, resolveUris, uris } = this.props;
if (!isSearching && !this.state.resultsResolved) {
this.setState({ resultsResolved: true }, () => {
if (uris && uris.length > 0) {
resolveUris(uris);
}
});
}
} */
}
getSearchQuery() {
@@ -135,6 +136,7 @@ class SearchPage extends React.PureComponent {
claimSearchOptions: null,
claimSearchRun: false,
showTagResult: false,
resultsResolved: false,
});
search(keywords);
};
@@ -190,7 +192,7 @@ class SearchPage extends React.PureComponent {
};
render() {
const { isSearching, navigation, query, uris } = this.props;
const { isSearching, navigation, query, results } = this.props;
return (
<View style={searchStyle.container}>
@@ -208,15 +210,15 @@ class SearchPage extends React.PureComponent {
style={searchStyle.scrollContainer}
contentContainerStyle={searchStyle.scrollPadding}
keyboardShouldPersistTaps={'handled'}
data={uris}
keyExtractor={(item, index) => item}
data={results}
keyExtractor={(item, index) => item.claimId}
initialNumToRender={8}
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} batchResolve navigation={navigation} />
<FileResultItem key={item.claimId} result={item} style={searchStyle.resultItem} navigation={navigation} />
)}
/>
)}
+5 -2
View File
@@ -73,7 +73,7 @@ class SubscriptionsPage extends React.PureComponent {
};
componentDidMount() {
this.onComponentFocused();
// this.onComponentFocused();
}
componentWillReceiveProps(nextProps) {
@@ -115,7 +115,10 @@ class SubscriptionsPage extends React.PureComponent {
unsubscribeShortChannelUrls = () => {
// this should only have to happen once
const { subscribedChannels, channelUnsubscribe } = this.props;
const badSubs = subscribedChannels.filter(sub => sub.uri.split('#')[1].length < 5);
const badSubs = subscribedChannels.filter(sub => {
const parts = sub.uri.split('#');
return parts.length === 1 || parts[1].length < 5;
});
if (badSubs.length > 0) {
badSubs.forEach(sub => channelUnsubscribe(sub));
}
+6
View File
@@ -166,6 +166,8 @@ const discoverStyle = StyleSheet.create({
filePriceContainer: {
backgroundColor: Colors.NextLbryGreen,
justifyContent: 'center',
alignItems: 'center',
flexDirection: 'row',
position: 'absolute',
right: 8,
top: 8,
@@ -179,6 +181,10 @@ const discoverStyle = StyleSheet.create({
textAlign: 'center',
color: '#0c604b',
},
filePriceIcon: {
marginRight: 2,
color: '#0c604b',
},
rightHeaderIcon: {
marginRight: 16,
},
-1
View File
@@ -24,7 +24,6 @@ const downloadsStyle = StyleSheet.create({
paddingLeft: 16,
paddingRight: 16,
marginTop: 16,
marginBottom: 60,
},
scrollPadding: {
marginTop: -16,
+22
View File
@@ -120,6 +120,28 @@ 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,6 +170,8 @@ const filePageStyle = StyleSheet.create({
filePriceContainer: {
backgroundColor: Colors.NextLbryGreen,
justifyContent: 'center',
alignItems: 'center',
flexDirection: 'row',
position: 'absolute',
right: 16,
top: 16,
@@ -183,6 +185,9 @@ const filePageStyle = StyleSheet.create({
textAlign: 'center',
color: '#0c604b',
},
filePriceIcon: {
marginRight: 2,
},
actions: {
flexDirection: 'row',
justifyContent: 'space-between',
+7 -2
View File
@@ -27,11 +27,16 @@ const walletStyle = StyleSheet.create({
},
address: {
fontFamily: 'Inter-UI-Regular',
letterSpacing: 0.8,
borderWidth: 1,
borderRadius: 16,
borderStyle: 'dashed',
borderColor: '#cccccc',
borderColor: '#e1e1e1',
backgroundColor: '#f9f9f9',
padding: 8,
paddingTop: 8,
paddingLeft: 8,
paddingRight: 8,
paddingBottom: 6,
width: '85%',
},
button: {