Redux #115

Merged
6ea86b96 merged 57 commits from redux into redux 2017-05-05 22:55:12 +02:00
2 changed files with 38 additions and 107 deletions
Showing only changes of commit 89e91c6d8a - Show all commits

View file

@ -8,6 +8,7 @@ import rewards from 'rewards.js';
import lbryio from 'lbryio.js'; import lbryio from 'lbryio.js';
import {BusyMessage, Thumbnail} from 'component/common.js'; import {BusyMessage, Thumbnail} from 'component/common.js';
import FileList from 'component/fileList' import FileList from 'component/fileList'
import SubHeader from 'component/subHeader'
class FileListDownloaded extends React.Component { class FileListDownloaded extends React.Component {
render() { render() {
@ -17,25 +18,21 @@ class FileListDownloaded extends React.Component {
navigate, navigate,
} = this.props } = this.props
let content
if (fetching) { if (fetching) {
return ( content = <BusyMessage message="Loading" />
<main className="page">
<BusyMessage message="Loading" />
</main>
);
} else if (!downloadedContent.length) { } else if (!downloadedContent.length) {
return ( content = <span>You haven't downloaded anything from LBRY yet. Go <Link href="#" onClick={() => navigate('discover')} label="search for your first download" />!</span>
<main className="page">
<span>You haven't downloaded anything from LBRY yet. Go <Link href="#" onClick={() => navigate('discover')} label="search for your first download" />!</span>
</main>
);
} else { } else {
return ( content = <FileList fileInfos={downloadedContent} hidePrices={true} />
<main className="page">
<FileList fileInfos={downloadedContent} hidePrices={true} />
</main>
);
} }
return (
<main className="page">
<SubHeader />
{content}
</main>
)
} }
} }

View file

@ -8,6 +8,7 @@ import rewards from 'rewards.js';
import lbryio from 'lbryio.js'; import lbryio from 'lbryio.js';
import {BusyMessage, Thumbnail} from 'component/common.js'; import {BusyMessage, Thumbnail} from 'component/common.js';
import FileList from 'component/fileList' import FileList from 'component/fileList'
import SubHeader from 'component/subHeader'
class FileListPublished extends React.Component { class FileListPublished extends React.Component {
componentDidUpdate() { componentDidUpdate() {
@ -15,17 +16,20 @@ class FileListPublished extends React.Component {
} }
_requestPublishReward() { _requestPublishReward() {
lbryio.call('reward', 'list', {}).then(function(userRewards) { // TODO this is throwing an error now
//already rewarded // Error: LBRY internal API is disabled
if (userRewards.filter(function (reward) { //
return reward.RewardType == rewards.TYPE_FIRST_PUBLISH && reward.TransactionID // lbryio.call('reward', 'list', {}).then(function(userRewards) {
}).length) { // //already rewarded
return // if (userRewards.filter(function (reward) {
} // return reward.RewardType == rewards.TYPE_FIRST_PUBLISH && reward.TransactionID
else { // }).length) {
rewards.claimReward(rewards.TYPE_FIRST_PUBLISH).catch(() => {}) // return
} // }
}) // else {
// rewards.claimReward(rewards.TYPE_FIRST_PUBLISH).catch(() => {})
// }
// })
} }
render() { render() {
@ -35,92 +39,22 @@ class FileListPublished extends React.Component {
navigate, navigate,
} = this.props } = this.props
let content
if (fetching) { if (fetching) {
return ( content = <BusyMessage message="Loading" />
<main className="page">
<BusyMessage message="Loading" />
</main>
);
} else if (!publishedContent.length) { } else if (!publishedContent.length) {
return ( content = <span>You haven't downloaded anything from LBRY yet. Go <Link href="#" onClick={() => navigate('discover')} label="search for your first download" />!</span>
<main className="page">
<span>You haven't downloaded anything from LBRY yet. Go <Link href="#" onClick={() => navigate('discover')} label="search for your first download" />!</span>
</main>
);
} else { } else {
return ( content = <FileList fileInfos={publishedContent} hidePrices={true} />
<main className="page">
<FileList fileInfos={publishedContent} hidePrices={true} />
</main>
);
} }
return (
<main className="page">
<SubHeader />
{content}
</main>
)
} }
} }
// const FileListPublished = React.createClass({
// _isMounted: false,
// getInitialState: function () {
// return {
// fileInfos: null,
// };
// },
// _requestPublishReward: function() {
// lbryio.call('reward', 'list', {}).then(function(userRewards) {
// //already rewarded
// if (userRewards.filter(function (reward) {
// return reward.RewardType == rewards.TYPE_FIRST_PUBLISH && reward.TransactionID;
// }).length) {
// return;
// }
// else {
// rewards.claimReward(rewards.TYPE_FIRST_PUBLISH).catch(() => {})
// }
// });
// },
// componentDidMount: function () {
// this._isMounted = true;
// this._requestPublishReward();
// document.title = "Published Files";
// lbry.claim_list_mine().then((claimInfos) => {
// if (!this._isMounted) { return; }
// lbry.file_list().then((fileInfos) => {
// if (!this._isMounted) { return; }
// const myClaimOutpoints = claimInfos.map(({txid, nout}) => txid + ':' + nout);
// this.setState({
// fileInfos: fileInfos.filter(({outpoint}) => myClaimOutpoints.includes(outpoint)),
// });
// });
// });
// },
// componentWillUnmount: function() {
// this._isMounted = false;
// },
// render: function () {
// if (this.state.fileInfos === null) {
// return (
// <main className="page">
// <BusyMessage message="Loading" />
// </main>
// );
// }
// else if (!this.state.fileInfos.length) {
// return (
// <main className="page">
// <span>You haven't published anything to LBRY yet.</span> Try <Link href="?publish" label="publishing" />!
// </main>
// );
// }
// else {
// return (
// <main className="page">
// <FileList fileInfos={this.state.fileInfos} />
// </main>
// );
// }
// }
// });
export default FileListPublished export default FileListPublished