diff --git a/helpers/errorHandlers.js b/helpers/errorHandlers.js index e170a9aa..8077cfa3 100644 --- a/helpers/errorHandlers.js +++ b/helpers/errorHandlers.js @@ -5,25 +5,25 @@ module.exports = { let status, message; // check for daemon being turned off if (error.code === 'ECONNREFUSED') { - status = 503; + status = 200; message = 'Connection refused. The daemon may not be running.'; - // check for errors from the daemon - } else if (error.response) { - status = error.response.status || 500; - if (error.response.data) { - if (error.response.data.message) { - message = error.response.data.message; - } else if (error.response.data.error) { - message = error.response.data.error.message; - } else { - message = error.response.data; - } - } else { - message = error.response; - } + // // check for errors from the daemon + // } else if (error.response) { + // status = error.response.status || 500; + // if (error.response.data) { + // if (error.response.data.message) { + // message = error.response.data.message; + // } else if (error.response.data.error) { + // message = error.response.data.error.message; + // } else { + // message = error.response.data; + // } + // } else { + // message = error.response; + // } // check for thrown errors } else if (error.message) { - status = 400; + status = 200; message = error.message; // fallback for everything else } else { diff --git a/helpers/lbryApi.js b/helpers/lbryApi.js index 25ee96cd..ac4c3280 100644 --- a/helpers/lbryApi.js +++ b/helpers/lbryApi.js @@ -10,13 +10,13 @@ function handleLbrynetResponse ({ data }, resolve, reject) { // check for an error if (data.result.error) { logger.debug('Lbrynet api error:', data.result.error); - reject(data.result.error); + reject(new Error(data.result.error)); return; }; resolve(data.result); return; } - // fallback in case the just timed out + // fallback in case it just timed out reject(JSON.stringify(data)); } diff --git a/react/actions/show.js b/react/actions/show.js index 1db4e443..ed30d7c2 100644 --- a/react/actions/show.js +++ b/react/actions/show.js @@ -19,29 +19,3 @@ export function updateRequestWithAssetRequest (name, id, channelName, channelId, extension, }; }; - -export function updateChannelData (name, longId, shortId) { - return { - type: actions.CHANNEL_DATA_UPDATE, - name, - longId, - shortId, - }; -}; - -export function updateChannelClaimsData (claims, currentPage, totalPages, totalClaims) { - return { - type: actions.CHANNEL_CLAIMS_DATA_UPDATE, - claims, - currentPage, - totalPages, - totalClaims, - }; -}; - -export function updateAssetData (data) { - return { - type: actions.ASSET_DATA_UPDATE, - data, - }; -}; diff --git a/react/components/AssetDisplay/index.js b/react/components/AssetDisplay/index.js index 8a0ed5cc..0917c260 100644 --- a/react/components/AssetDisplay/index.js +++ b/react/components/AssetDisplay/index.js @@ -39,9 +39,12 @@ class AssetDisplay extends React.Component { const url = `/api/file-is-available/${this.props.name}/${this.props.claimId}`; return new Promise((resolve, reject) => { Request(url) - .then(isAvailable => { - console.log('/api/file-is-available response:', isAvailable); - resolve(isAvailable); + .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); @@ -53,9 +56,12 @@ class AssetDisplay extends React.Component { const url = `/api/claim-get/${this.props.name}/${this.props.claimId}`; return new Promise((resolve, reject) => { Request(url) - .then(response => { - console.log('/api/claim-get response:', response); - resolve(true); + .then(({success, message}) => { + console.log('/api/claim-get response:', success, message); + if (success) { + return resolve(true); + } + reject(new Error(message)); }) .catch(error => { reject(error); @@ -65,6 +71,11 @@ class AssetDisplay extends React.Component { render () { return (
Checking to see if Spee.ch has your asset locally...
+Sit tight, we're searching the LBRY blockchain for your asset!
diff --git a/react/components/ChannelClaimsDisplay/index.js b/react/components/ChannelClaimsDisplay/index.js new file mode 100644 index 00000000..8af9ca24 --- /dev/null +++ b/react/components/ChannelClaimsDisplay/index.js @@ -0,0 +1,79 @@ +import React from 'react/index'; +import AssetPreview from 'components/AssetPreview'; +import request from 'utils/request'; + +class ChannelClaimsDisplay extends React.Component { + constructor (props) { + super(props); + this.state = { + error : null, + claims : null, + currentPage: null, + totalPages : null, + totalClaims: null, + }; + this.updateClaimsData = this.updateClaimsData.bind(this); + } + componentDidMount () { + this.updateClaimsData(1); + } + updateClaimsData (page) { + const name = this.props.name; + const longId = this.props.longId; + const url = `/api/channel-claims/${name}/${longId}/${page}`; + const that = this; + return request(url) + .then(({ success, message, data }) => { + console.log('api/channel-claims response:', data); + if (!success) { + return that.setState({error: message}); + } + this.setState({ + claims : data.claims, + currentPage: data.currentPage, + totalPages : data.totalPages, + totalClaims: data.totalResults, + }); + }) + .catch((error) => { + that.setState({error: error.message}); + }); + } + render () { + return ( +{this.state.error}
+total pages: {this.state.totalPages}
+total claims: {this.state.totalClaims}
+ {this.state.claims && +current page: {this.state.currentPage}
+ {(this.state.currentPage < this.state.totalPages) && } +{this.state.error}
-current page: {this.props.currentPage}
-total pages: {this.props.totalPages}
-total claims: {this.props.totalClaims}
-full channel id: {this.props.channel.longId ? this.props.channel.longId : 'loading...'}
-short channel id: {this.props.channel.shortId ? this.props.channel.shortId : 'loading...'}
+full channel id: {this.state.longId ? this.state.longId : 'loading...'}
+short channel id: {this.state.shortId ? this.state.shortId : 'loading...'}