diff --git a/dist.zip b/dist.zip index 0ea700615..a1f00be82 100644 Binary files a/dist.zip and b/dist.zip differ diff --git a/dist/index.html b/dist/index.html index 0378506e9..1d42421a7 100644 --- a/dist/index.html +++ b/dist/index.html @@ -34,6 +34,7 @@ + diff --git a/js/app.js b/js/app.js index 69a2f41f7..ef6dc5cbe 100644 --- a/js/app.js +++ b/js/app.js @@ -4,7 +4,7 @@ var App = React.createClass({ var match, param, val; [match, param, val] = window.location.search.match(/\??([^=]*)(?:=(.*))?/); - if (['settings', 'help', 'start', 'watch', 'report', 'files'].indexOf(param) != -1) { + if (['settings', 'help', 'start', 'watch', 'report', 'files', 'claim'].indexOf(param) != -1) { var viewingPage = param; } else { var viewingPage = 'home'; @@ -56,6 +56,8 @@ var App = React.createClass({ return ; } else if (this.state.viewingPage == 'start') { return ; + } else if (this.state.viewingPage == 'claim') { + return ; } } }); \ No newline at end of file diff --git a/js/lbry.js b/js/lbry.js index 25bcb4927..29f0e04f7 100644 --- a/js/lbry.js +++ b/js/lbry.js @@ -77,6 +77,14 @@ lbry.getStartNotice = function(callback) { lbry.call('get_start_notice', {}, callback); } +lbry.checkFirstRun = function(callback) { + lbry.call('is_first_run', {}, callback); +} + +lbry.getNewAddress = function(callback) { + lbry.call('get_new_address', {}, callback); +} + lbry.getSettings = function(callback) { lbry.call('get_settings', {}, callback); }; diff --git a/js/main.js b/js/main.js index 6305ccfa3..ed8398146 100644 --- a/js/main.js +++ b/js/main.js @@ -4,7 +4,19 @@ var init = function() { ReactDOM.render( , canvas); + // On home page, if the balance is 0, display claim code page instead of home page. + // Find somewhere better for this logic + if (window.location.search == '' || window.location.search == '?' || window.location.search == 'home') { + lbry.getBalance((balance) => { + if (balance <= 0) { + window.location.href = '?claim'; + } else { + ReactDOM.render(, canvas); + } + }); + } else { + ReactDOM.render(, canvas); + } }}/>, canvas ); diff --git a/js/page/claim_code.js b/js/page/claim_code.js new file mode 100644 index 000000000..4a53d9893 --- /dev/null +++ b/js/page/claim_code.js @@ -0,0 +1,89 @@ +var claimCodePageStyle = { + textAlign: 'center', +}, claimCodeContentStyle = { + display: 'inline-block', + textAlign: 'left', + width: '600px', +}, claimCodeLabelStyle = { + display: 'inline-block', + cursor: 'default', + width: '130px', +}; + +var ClaimCodePage = React.createClass({ + getInitialState: function() { + return { + submitting: false, + } + }, + handleSubmit: function() { + if (!this.refs.code.value) { + alert('Please enter an invitation code or choose "Skip."') + } + + this.setState({ + submitting: true + }); + + lbry.getNewAddress((address) => { + var code = this.refs.code.value; + var email = this.refs.email.value; + + var xhr = new XMLHttpRequest; + xhr.addEventListener('load', () => { + var response = JSON.parse(xhr.responseText); + + if (response.success) { + alert('Your invite code has been redeemed! 200 LBRY credits will be added to your balance shortly.'); + // Send them to "landing" instead of "home" (home will just trigger the message all over again until the credits arrive) + window.location = '?landing'; + } else { + alert("You've entered an invalid code, or one that's already been claimed. Please check your code and try again."); + this.setState({ + submitting: false + }); + } + }); + + xhr.addEventListener('error', () => { + this.setState({ + submitting: false + }); + alert('LBRY couldn\'t connect to our servers to confirm your invitation code. Please check your ' + + 'internet connection. If you continue to have problems, you can still browse LBRY and ' + + 'visit the Settings page to redeem your code later.'); + }); + + xhr.open('POST', 'https://invites.lbry.io', true); + xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); + xhr.send('code=' + code + '&address=' + address + (email ? ('&email=' + email) : '')); + }); + }, + handleSkip: function() { + alert('Welcome to LBRY! You can visit the Settings page to redeem an invite code at any time.'); + window.location = '?landing'; + }, + render: function() { + return ( +
+

Claim your beta invitation code

+
+

Thanks for beta testing LBRY! Enter your invitation code below to receive your 200 free LBRY credits.

+

You may also enter your email address. This will add you to our mailing list (if you're not already on it) + as well as making you eligible for future rewards for beta testers.

+
+
+
+
+
+
+
+
+ + +
+
+ ); + } +}); \ No newline at end of file diff --git a/js/page/settings.js b/js/page/settings.js index 31b7c1d27..02bcd7824 100644 --- a/js/page/settings.js +++ b/js/page/settings.js @@ -113,6 +113,11 @@ var SettingsPage = React.createClass({ Help make LBRY better by contributing diagnostic data about my usage +
+

Claim invite code

+ +
+
diff --git a/js/page/watch.js b/js/page/watch.js index de35959d4..e47b434b2 100644 --- a/js/page/watch.js +++ b/js/page/watch.js @@ -44,7 +44,7 @@ var WatchPage = React.createClass({ {this.state.loadStatusMessage}... );