First run changes #103
2 changed files with 18 additions and 25 deletions
|
@ -49,6 +49,9 @@ class FileDownloadButton extends React.PureComponent {
|
||||||
onButtonLayout,
|
onButtonLayout,
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
|
console.log('uri=' + uri);
|
||||||
|
console.log(fileInfo);
|
||||||
|
|
||||||
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,
|
const progress = fileInfo && fileInfo.written_bytes ? (fileInfo.written_bytes / fileInfo.total_bytes) * 100 : 0,
|
||||||
label = fileInfo ? __('%progress%% complete', { progress: progress.toFixed(0) }) : __('Connecting...');
|
label = fileInfo ? __('%progress%% complete', { progress: progress.toFixed(0) }) : __('Connecting...');
|
||||||
|
|
|
@ -179,7 +179,8 @@ class FilePage extends React.PureComponent {
|
||||||
(this.state.fileGetStarted || prevPurchasedUris.length !== purchasedUris.length) &&
|
(this.state.fileGetStarted || prevPurchasedUris.length !== purchasedUris.length) &&
|
||||||
NativeModules.UtilityModule
|
NativeModules.UtilityModule
|
||||||
) {
|
) {
|
||||||
if (purchasedUris.includes(uri)) {
|
const { permanent_url: permanentUrl } = claim;
|
||||||
|
if (purchasedUris.includes(uri) || purchasedUris.includes(permanentUrl)) {
|
||||||
const { nout, txid } = claim;
|
const { nout, txid } = claim;
|
||||||
const outpoint = `${txid}:${nout}`;
|
const outpoint = `${txid}:${nout}`;
|
||||||
NativeModules.UtilityModule.queueDownload(outpoint);
|
NativeModules.UtilityModule.queueDownload(outpoint);
|
||||||
|
@ -252,15 +253,7 @@ class FilePage extends React.PureComponent {
|
||||||
const mediaType = Lbry.getMediaType(contentType);
|
const mediaType = Lbry.getMediaType(contentType);
|
||||||
const isViewable = mediaType === 'image' || mediaType === 'text';
|
const isViewable = mediaType === 'image' || mediaType === 'text';
|
||||||
if (claim && costInfo && costInfo.cost === 0 && !this.state.autoGetAttempted && isViewable) {
|
if (claim && costInfo && costInfo.cost === 0 && !this.state.autoGetAttempted && isViewable) {
|
||||||
this.setState(
|
this.setState({ autoGetAttempted: true }, () => this.checkStoragePermissionForDownload());
|
||||||
{
|
|
||||||
autoGetAttempted: true,
|
|
||||||
downloadPressed: true,
|
|
||||||
autoPlayMedia: true,
|
|
||||||
stopDownloadConfirmed: false,
|
|
||||||
},
|
|
||||||
() => purchaseUri(claim.permanent_url, costInfo, true)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -429,7 +422,7 @@ class FilePage extends React.PureComponent {
|
||||||
// update the configured download folder and then download
|
// update the configured download folder and then download
|
||||||
NativeModules.UtilityModule.getDownloadDirectory().then(downloadDirectory => {
|
NativeModules.UtilityModule.getDownloadDirectory().then(downloadDirectory => {
|
||||||
Lbry.settings_set({
|
Lbry.settings_set({
|
||||||
key: 'download_directory',
|
key: 'download_dir',
|
||||||
value: downloadDirectory,
|
value: downloadDirectory,
|
||||||
})
|
})
|
||||||
.then(() => this.performDownload())
|
.then(() => this.performDownload())
|
||||||
|
@ -616,12 +609,12 @@ class FilePage extends React.PureComponent {
|
||||||
};
|
};
|
||||||
|
|
||||||
onFileDownloadButtonPressed = () => {
|
onFileDownloadButtonPressed = () => {
|
||||||
const { costInfo, contentType, purchaseUri, setPlayerVisible } = this.props;
|
const { claim, costInfo, contentType, purchaseUri, setPlayerVisible } = this.props;
|
||||||
const { uri } = this.state;
|
|
||||||
const mediaType = Lbry.getMediaType(contentType);
|
const mediaType = Lbry.getMediaType(contentType);
|
||||||
const isPlayable = mediaType === 'video' || mediaType === 'audio';
|
const isPlayable = mediaType === 'video' || mediaType === 'audio';
|
||||||
const isViewable = mediaType === 'image' || mediaType === 'text';
|
const isViewable = mediaType === 'image' || mediaType === 'text';
|
||||||
|
|
||||||
|
const { permanent_url: uri } = claim;
|
||||||
NativeModules.Firebase.track('purchase_uri', { uri: uri });
|
NativeModules.Firebase.track('purchase_uri', { uri: uri });
|
||||||
|
|
||||||
if (!isPlayable) {
|
if (!isPlayable) {
|
||||||
|
@ -645,7 +638,6 @@ class FilePage extends React.PureComponent {
|
||||||
};
|
};
|
||||||
|
|
||||||
checkStoragePermissionForDownload = () => {
|
checkStoragePermissionForDownload = () => {
|
||||||
this.setState({ downloadPressed: true }, () => {
|
|
||||||
// check if we the permission to write to external storage has been granted
|
// check if we the permission to write to external storage has been granted
|
||||||
NativeModules.UtilityModule.canReadWriteStorage().then(canReadWrite => {
|
NativeModules.UtilityModule.canReadWriteStorage().then(canReadWrite => {
|
||||||
if (!canReadWrite) {
|
if (!canReadWrite) {
|
||||||
|
@ -655,7 +647,6 @@ class FilePage extends React.PureComponent {
|
||||||
this.performDownload();
|
this.performDownload();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
performDownload = () => {
|
performDownload = () => {
|
||||||
|
@ -957,8 +948,7 @@ class FilePage extends React.PureComponent {
|
||||||
|
|
||||||
{((isPlayable && !completed && !canLoadMedia) ||
|
{((isPlayable && !completed && !canLoadMedia) ||
|
||||||
canOpen ||
|
canOpen ||
|
||||||
(!completed && !this.state.streamingMode)) &&
|
(!completed && !this.state.streamingMode)) && (
|
||||||
!this.state.downloadPressed && (
|
|
||||||
<FileDownloadButton
|
<FileDownloadButton
|
||||||
uri={claim && claim.permanent_url ? claim.permanent_url : uri}
|
uri={claim && claim.permanent_url ? claim.permanent_url : uri}
|
||||||
style={filePageStyle.downloadButton}
|
style={filePageStyle.downloadButton}
|
||||||
|
|
Loading…
Reference in a new issue