import React from 'react'; import PropTypes from 'prop-types'; import ProgressBar from 'components/ProgressBar'; import Request from 'utils/request'; import { LOCAL_CHECK, SEARCHING, UNAVAILABLE, AVAILABLE } from 'constants/asset_display_states'; class AssetDisplay extends React.Component { constructor (props) { super(props); this.state = { error : null, status: LOCAL_CHECK, }; this.isLocalFileAvailableOnServer = this.isLocalFileAvailableOnServer.bind(this); this.triggerGetAssetOnServer = this.triggerGetAssetOnServer.bind(this); } componentDidMount () { const that = this; this.isLocalFileAvailableOnServer() .then(isAvailable => { if (!isAvailable) { console.log('file is not yet available'); that.setState({status: SEARCHING}); return that.triggerGetAssetOnServer(); } }) .then(() => { that.setState({status: AVAILABLE}); }) .catch(error => { that.setState({ status: UNAVAILABLE, error : error.message, }); }); } isLocalFileAvailableOnServer () { console.log(`checking if file is available for ${this.props.name}#${this.props.claimId}`); const url = `/api/file-is-available/${this.props.name}/${this.props.claimId}`; return new Promise((resolve, reject) => { Request(url) .then(({success, message, data: isAvailable}) => { if (success) { console.log('/api/file-is-available response:', isAvailable); return resolve(isAvailable); } reject(new Error(message)); }) .catch(error => { reject(error); }); }); } triggerGetAssetOnServer () { console.log(`getting claim for ${this.props.name}#${this.props.claimId}`); const url = `/api/claim-get/${this.props.name}/${this.props.claimId}`; return new Promise((resolve, reject) => { Request(url) .then(({success, message}) => { console.log('/api/claim-get response:', success, message); if (success) { return resolve(true); } reject(new Error(message)); }) .catch(error => { reject(error); }); }); } render () { return (
Checking to see if Spee.ch has your asset locally...
Sit tight, we're searching the LBRY blockchain for your asset!
Curious what magic is happening here? Learn more.
Unfortunately, we couldn't download your asset from LBRY. You can help us out by sharing the below error message in the LBRY discord.
{this.state.error}
Unsupported file type
); } })() }