Rewrite search to use Lighthouse RPC calls

This commit is contained in:
Alex Liebowitz 2016-08-18 03:14:38 -04:00
parent 9d7f82e309
commit 1a66fafd2d
4 changed files with 21 additions and 6 deletions

1
dist/index.html vendored
View file

@ -26,6 +26,7 @@
<script src="./js/mediaelement/jquery.js"></script>
<script src="./js/mediaelement/mediaelement-and-player.min.js"></script>
<script src="./js/lbry.js"></script>
<script src="./js/lighthouse.js"></script>
<script src="./js/component/common.js"></script>
<script src="./js/component/form.js"></script>
<script src="./js/component/link.js"></script>

View file

@ -110,7 +110,7 @@ lbry.sendToAddress = function(amount, address, callback, errorCallback)
lbry.search = function(query, callback)
{
lbry.call("search_nametrie", { "search": query }, callback);
lbry.lighthouse.call('search', [query], callback);
}
lbry.resolveName = function(name, callback) {

14
js/lighthouse.js Normal file
View file

@ -0,0 +1,14 @@
lbry.lighthouse = {
servers: [
'http://lighthouse1.lbry.io:50005',
'http://lighthouse2.lbry.io:50005',
'http://lighthouse3.lbry.io:50005',
],
path: '/',
call: function(method, params, callback, errorCallback, connectFailedCallback) {
lbry.jsonrpc_call(this.server + this.path, method, params, callback, errorCallback, connectFailedCallback);
},
};
lbry.lighthouse.server = lbry.lighthouse.servers[Math.round(Math.random() * (lbry.lighthouse.servers.length - 1))];

View file

@ -37,10 +37,10 @@ var SearchResults = React.createClass({
render: function() {
var rows = [];
this.props.results.forEach(function(result) {
if (!result.nsfw) {
if (!result.value.nsfw) {
rows.push(
<SearchResultRow key={result.name} name={result.name} title={result.title} imgUrl={result.thumbnail}
description={result.description} cost_est={result.cost_est} />
<SearchResultRow key={result.name} name={result.name} title={result.value.title} imgUrl={result.value.thumbnail}
description={result.value.description} cost={result.cost} />
);
}
});
@ -91,7 +91,7 @@ var SearchResultRow = React.createClass({
</div>
<div className="span9">
<span style={searchRowCostStyle}>
<CreditAmount amount={this.props.cost_est} isEstimate={true}/>
<CreditAmount amount={this.props.cost} isEstimate={true}/>
</span>
<div className="meta">lbry://{this.props.name}</div>
<h3 style={searchRowTitleStyle}><a href={'/?show=' + this.props.name}>{this.props.title}</a></h3>
@ -142,7 +142,7 @@ var FeaturedContentItem = React.createClass({
return null;
}
return <SearchResultRow name={this.props.name} title={this.state.title} imgUrl={this.state.metadata.thumbnail}
description={this.state.metadata.description} cost_est={this.state.amount} />;
description={this.state.metadata.description} cost={this.state.amount} />;
}
});