Merge pull request #36 from lbryio/channels

More Channels fixes
This commit is contained in:
alexliebowitz 2017-04-11 00:36:26 -04:00 committed by GitHub
commit 4af89b4685
4 changed files with 34 additions and 22 deletions

View file

@ -261,7 +261,6 @@ export let FileActions = React.createClass({
componentDidMount: function() { componentDidMount: function() {
this._isMounted = true; this._isMounted = true;
this._fileInfoSubscribeId = lbry.fileInfoSubscribe(this.props.outpoint, this.onFileInfoUpdate); this._fileInfoSubscribeId = lbry.fileInfoSubscribe(this.props.outpoint, this.onFileInfoUpdate);
lbry.getStreamAvailability(this.props.uri, (availability) => {
lbry.get_availability({uri: this.props.uri}, (availability) => { lbry.get_availability({uri: this.props.uri}, (availability) => {
if (this._isMounted) { if (this._isMounted) {
this.setState({ this.setState({

View file

@ -27,8 +27,8 @@ var SplashScreen = React.createClass({
isLagging: false isLagging: false
}); });
lbry.resolveName('one', () => { lbry.resolve({uri: 'lbry://one'}).then(() => {
window.sessionStorage.setItem('loaded', 'y') window.sessionStorage.setItem('loaded', 'y')
this.props.onLoadDone(); this.props.onLoadDone();
}); });
return; return;

View file

@ -161,14 +161,21 @@ export let FileList = React.createClass({
seenUris = {}; seenUris = {};
const fileInfosSorted = this._sortFunctions[this.state.sortBy](this.props.fileInfos); const fileInfosSorted = this._sortFunctions[this.state.sortBy](this.props.fileInfos);
for (let {name, outpoint, metadata: {stream: {metadata}}, mime_type, claim_id} of fileInfosSorted) { for (let {outpoint, name, channel_name, metadata: {stream: {metadata}}, mime_type, claim_id, has_signature, signature_is_valid} of fileInfosSorted) {
if (!metadata || seenUris[name]) { if (!metadata || seenUris[name]) {
continue; continue;
} }
let fileUri;
if (channel_name === undefined) {
fileUri = uri.buildLbryUri({name});
} else {
fileUri = uri.buildLbryUri({name: channel_name, path: name});
}
seenUris[name] = true; seenUris[name] = true;
content.push(<FileTileStream key={outpoint} outpoint={outpoint} uri={uri.buildLbryUri({name, claimId: claim_id})} hideOnRemove={true} content.push(<FileTileStream key={outpoint} outpoint={outpoint} uri={fileUri} hideOnRemove={true}
hidePrice={this.props.hidePrices} metadata={metadata} contentType={mime_type} />); hidePrice={this.props.hidePrices} metadata={metadata} contentType={mime_type}
hasSignature={has_signature} signatureIsValid={signature_is_valid} />);
} }
return ( return (

View file

@ -171,44 +171,50 @@ var PublishPage = React.createClass({
}); });
const name = rawName.toLowerCase(); const name = rawName.toLowerCase();
lbry.resolve({uri: name}).then((info) => { lbry.getMyClaim(name, (myClaimInfo) => {
if (name != this.refs.name.getValue().toLowerCase()) { if (name != this.refs.name.getValue().toLowerCase()) {
// A new name has been typed already, so bail // A new name has been typed already, so bail
return; return;
} }
lbry.getMyClaim(name, (myClaimInfo) => { lbry.resolve({uri: name}).then((claimInfo) => {
lbry.getClaimInfo(name, (claimInfo) => { if (name != this.refs.name.getValue()) {
if (name != this.refs.name.getValue()) { return;
return; }
}
const topClaimIsMine = (myClaimInfo && myClaimInfo.amount >= claimInfo.amount); if (!claimInfo) {
this.setState({
name: name,
nameResolved: false,
myClaimExists: false,
});
} else {
const topClaimIsMine = (myClaimInfo && myClaimInfo.claim.amount >= claimInfo.claim.amount);
const newState = { const newState = {
name: name, name: name,
nameResolved: true, nameResolved: true,
topClaimValue: parseFloat(claimInfo.amount), topClaimValue: parseFloat(claimInfo.claim.amount),
myClaimExists: !!myClaimInfo, myClaimExists: !!myClaimInfo,
myClaimValue: myClaimInfo ? parseFloat(myClaimInfo.amount) : null, myClaimValue: myClaimInfo ? parseFloat(myClaimInfo.claim.amount) : null,
myClaimMetadata: myClaimInfo ? myClaimInfo.value : null, myClaimMetadata: myClaimInfo ? myClaimInfo.value : null,
topClaimIsMine: topClaimIsMine, topClaimIsMine: topClaimIsMine,
}; };
if (topClaimIsMine) { if (topClaimIsMine) {
newState.bid = myClaimInfo.amount; newState.bid = myClaimInfo.claim.amount;
} else if (this.state.myClaimMetadata) { } else if (this.state.myClaimMetadata) {
// Just changed away from a name we have a claim on, so clear pre-fill // Just changed away from a name we have a claim on, so clear pre-fill
newState.bid = ''; newState.bid = '';
} }
this.setState(newState); this.setState(newState);
}
}, () => { // Assume an error means the name is available
this.setState({
name: name,
nameResolved: false,
myClaimExists: false,
}); });
}); });
}, () => { // Assume an error means the name is available
this.setState({
name: name,
nameResolved: false,
myClaimExists: false,
});
}); });
}, },
handleBidChange: function(event) { handleBidChange: function(event) {