auto-fetch image and text types #87
1 changed files with 18 additions and 0 deletions
|
@ -61,6 +61,7 @@ class FilePage extends React.PureComponent {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
this.state = {
|
this.state = {
|
||||||
|
attemptAutoGet: false,
|
||||||
autoPlayMedia: false,
|
autoPlayMedia: false,
|
||||||
autoDownloadStarted: false,
|
autoDownloadStarted: false,
|
||||||
downloadButtonShown: false,
|
downloadButtonShown: false,
|
||||||
|
@ -189,10 +190,12 @@ class FilePage extends React.PureComponent {
|
||||||
const {
|
const {
|
||||||
claim,
|
claim,
|
||||||
contentType,
|
contentType,
|
||||||
|
costInfo,
|
||||||
fileInfo,
|
fileInfo,
|
||||||
isResolvingUri,
|
isResolvingUri,
|
||||||
resolveUri,
|
resolveUri,
|
||||||
navigation,
|
navigation,
|
||||||
|
purchaseUri,
|
||||||
searchRecommended,
|
searchRecommended,
|
||||||
title,
|
title,
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
@ -214,6 +217,21 @@ class FilePage extends React.PureComponent {
|
||||||
uri: this.state.uri,
|
uri: this.state.uri,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// attempt to retrieve images and html/text automatically once the claim is loaded, and it's free
|
||||||
|
const mediaType = Lbry.getMediaType(contentType);
|
||||||
|
const isViewable = mediaType === 'image' || mediaType === 'text';
|
||||||
|
if (claim && costInfo && costInfo.cost === 0 && !this.state.autoGetAttempted && isViewable) {
|
||||||
|
this.setState(
|
||||||
|
{
|
||||||
|
autoGetAttempted: true,
|
||||||
|
downloadPressed: true,
|
||||||
|
autoPlayMedia: true,
|
||||||
|
stopDownloadConfirmed: false,
|
||||||
|
},
|
||||||
|
() => purchaseUri(claim.permanent_url, costInfo, true)
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fetchFileInfo(props) {
|
fetchFileInfo(props) {
|
||||||
|
|
Loading…
Reference in a new issue