use remote api to fetch featured names
This commit is contained in:
parent
d628b9bda9
commit
5099fe3ab2
2 changed files with 27 additions and 6 deletions
15
js/lbry.js
15
js/lbry.js
|
@ -245,6 +245,21 @@ lbry.getCostInfoForName = function(name, callback, errorCallback) {
|
|||
});
|
||||
}
|
||||
|
||||
lbry.getFeaturedDiscoverNames = function(callback) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
var xhr = new XMLHttpRequest;
|
||||
xhr.open('GET', 'https://api.lbry.io/discover/list', true);
|
||||
xhr.onload = () => {
|
||||
if (xhr.status === 200) {
|
||||
resolve(JSON.parse(xhr.responseText));
|
||||
} else {
|
||||
reject(Error('Failed to fetch featured names.'));
|
||||
}
|
||||
};
|
||||
xhr.send();
|
||||
});
|
||||
}
|
||||
|
||||
lbry.getFileStatus = function(name, callback) {
|
||||
lbry.call('get_lbry_file', { 'name': name }, callback);
|
||||
}
|
||||
|
|
|
@ -65,20 +65,26 @@ var featuredContentLegendStyle = {
|
|||
};
|
||||
|
||||
var FeaturedContent = React.createClass({
|
||||
getInitialState: function() {
|
||||
return {
|
||||
featuredNames: [],
|
||||
};
|
||||
},
|
||||
componentWillMount: function() {
|
||||
lbry.getFeaturedDiscoverNames().then((featuredNames) => {
|
||||
this.setState({ featuredNames: featuredNames });
|
||||
});
|
||||
},
|
||||
render: function() {
|
||||
const toolTipText = ('Community Content is a public space where anyone can share content with the ' +
|
||||
'rest of the LBRY community. Bid on the names "one," "two," "three," "four" and ' +
|
||||
'"five" to put your content here!');
|
||||
|
||||
return (
|
||||
<div className="row-fluid">
|
||||
<div className="span6">
|
||||
<h3>Featured Content</h3>
|
||||
<FileTile name="coherence" />
|
||||
<FileTile name="itsadisaster" />
|
||||
<FileTile name="mikehill-blockbuster" />
|
||||
<FileTile name="bellflower" />
|
||||
<FileTile name="cinemasix" />
|
||||
|
||||
{ this.state.featuredNames.map((name) => { return <FileTile key={name} name={name} /> }) }
|
||||
</div>
|
||||
<div className="span6">
|
||||
<h3>
|
||||
|
|
Loading…
Reference in a new issue