diff --git a/app/src/component/subscribeButton/view.js b/app/src/component/subscribeButton/view.js index 86cf4f85..19b8d6bd 100644 --- a/app/src/component/subscribeButton/view.js +++ b/app/src/component/subscribeButton/view.js @@ -1,8 +1,8 @@ import React from 'react'; import { normalizeURI, parseURI } from 'lbry-redux'; import { NativeModules, Text, View, TouchableOpacity } from 'react-native'; -import Button from '../button'; -import Colors from '../../styles/colors'; +import Button from 'component/button'; +import Colors from 'styles/colors'; class SubscribeButton extends React.PureComponent { render() { @@ -11,7 +11,8 @@ class SubscribeButton extends React.PureComponent { isSubscribed, doChannelSubscribe, doChannelUnsubscribe, - style + style, + hideText } = this.props; let styles = []; @@ -35,7 +36,7 @@ class SubscribeButton extends React.PureComponent { icon={isSubscribed ? "heart-broken" : "heart"} iconColor={iconColor} solid={isSubscribed ? false : true} - text={subscriptionLabel} + text={hideText ? null : subscriptionLabel} onPress={() => { subscriptionHandler({ channelName: claimName, diff --git a/app/src/page/file/index.js b/app/src/page/file/index.js index 42b7bc3f..1baaca1f 100644 --- a/app/src/page/file/index.js +++ b/app/src/page/file/index.js @@ -1,6 +1,7 @@ import { connect } from 'react-redux'; import { doFetchFileInfo, + doFileGet, doPurchaseUri, doDeletePurchasedUri, doResolveUri, @@ -70,6 +71,7 @@ const perform = dispatch => ({ }, fetchFileInfo: uri => dispatch(doFetchFileInfo(uri)), fetchCostInfo: uri => dispatch(doFetchCostInfoForUri(uri)), + fileGet: (uri, saveFile) => dispatch(doFileGet(uri, saveFile)), notify: data => dispatch(doToast(data)), popDrawerStack: () => dispatch(doPopDrawerStack()), purchaseUri: (uri, costInfo, saveFile) => dispatch(doPurchaseUri(uri, costInfo, saveFile)), diff --git a/app/src/page/file/view.js b/app/src/page/file/view.js index e4b6bd72..36ddf5bc 100644 --- a/app/src/page/file/view.js +++ b/app/src/page/file/view.js @@ -63,6 +63,7 @@ class FilePage extends React.PureComponent { downloadPressed: false, fileViewLogged: false, fullscreenMode: false, + fileGetStarted: false, imageUrls: null, isLandscape: false, mediaLoaded: false, @@ -150,7 +151,7 @@ class FilePage extends React.PureComponent { const mediaType = Lbry.getMediaType(contentType); const isPlayable = mediaType === 'video' || mediaType === 'audio'; - if (prevPurchasedUris.length != purchasedUris.length && NativeModules.UtilityModule) { + if ((this.state.fileGetStarted || prevPurchasedUris.length !== purchasedUris.length) && NativeModules.UtilityModule) { if (purchasedUris.includes(uri)) { const { nout, txid } = claim; const outpoint = `${txid}:${nout}`; @@ -159,6 +160,7 @@ class FilePage extends React.PureComponent { if (!isPlayable && !this.state.fileViewLogged) { this.logFileView(uri, claim); } + this.setState({ fileGetStarted: false }); } NativeModules.UtilityModule.checkDownloads(); } @@ -499,6 +501,22 @@ class FilePage extends React.PureComponent { navigateBack(navigation, drawerStack, popDrawerStack); } + onSaveFilePressed = () => { + const { costInfo, fileGet, fileInfo, navigation, purchasedUris, purchaseUri } = this.props; + const { uri } = navigation.state.params; + + if (fileInfo || purchasedUris.includes(uri)) { + // file already in library or URI already purchased, use fileGet directly + this.setState({ fileGetStarted: true }, () => fileGet(uri, true)); + } else { + this.setState({ + downloadPressed: true, + autoPlayMedia: false, + stopDownloadConfirmed: false + }, () => purchaseUri(uri, costInfo, true)); + } + } + render() { const { balance, @@ -579,7 +597,10 @@ class FilePage extends React.PureComponent { const mediaType = Lbry.getMediaType(contentType); const isPlayable = mediaType === 'video' || mediaType === 'audio'; const { height, channel_name: channelName, value } = claim; - const showActions = !this.state.streamingMode && !this.state.fullscreenMode && !this.state.showImageViewer && !this.state.showWebView; + const showActions = (fileInfo && fileInfo.download_path) && + !this.state.fullscreenMode && + !this.state.showImageViewer && + !this.state.showWebView; const showFileActions = (fileInfo && fileInfo.download_path) && (completed || (fileInfo && !fileInfo.stopped && fileInfo.written_bytes < fileInfo.total_bytes)); const channelClaimId = claim && claim.signing_channel && claim.signing_channel.claim_id; @@ -754,6 +775,11 @@ class FilePage extends React.PureComponent { show={DateTime.SHOW_DATE} /> + {((isPlayable && !fileInfo) || (isPlayable && fileInfo && !fileInfo.download_path)) && +