diff --git a/app/main.js b/app/main.js index 8a66a4403..07aed14d0 100644 --- a/app/main.js +++ b/app/main.js @@ -107,7 +107,6 @@ function launchDaemon() { daemonSubprocess.stdout.on('data', (buf) => {console.log(String(buf).trim());}); daemonSubprocess.stderr.on('data', (buf) => {console.log(String(buf).trim());}); daemonSubprocess.on('exit', handleDaemonSubprocessExited); - console.log('lbrynet daemon has launched') } /* diff --git a/doitagain.sh b/doitagain.sh deleted file mode 100755 index 37564e1dd..000000000 --- a/doitagain.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash -rm -rf ~/.lbrynet/ -rm -rf ~/.lbryum/ -./node_modules/.bin/electron app diff --git a/ui/js/component/auth.js b/ui/js/component/auth.js index a36c6d48d..f0e1f1074 100644 --- a/ui/js/component/auth.js +++ b/ui/js/component/auth.js @@ -1,12 +1,11 @@ -import React from 'react'; -import lbryio from '../lbryio.js'; - -import Modal from './modal.js'; -import ModalPage from './modal-page.js'; -import {Link, RewardLink} from '../component/link.js'; -import {FormField, FormRow} from '../component/form.js'; -import {CreditAmount} from '../component/common.js'; -import rewards from '../rewards.js'; +import React from "react"; +import lbryio from "../lbryio.js"; +import Modal from "./modal.js"; +import ModalPage from "./modal-page.js"; +import {Link, RewardLink} from "../component/link.js"; +import {FormRow} from "../component/form.js"; +import {CreditAmount, Address} from "../component/common.js"; +import {getLocal, getSession, setSession, setLocal} from '../utils.js'; const SubmitEmailStage = React.createClass({ @@ -22,6 +21,9 @@ const SubmitEmailStage = React.createClass({ email: event.target.value, }); }, + onEmailSaved: function(email) { + this.props.setStage("confirm", { email: email }) + }, handleSubmit: function(event) { event.preventDefault(); @@ -29,10 +31,10 @@ const SubmitEmailStage = React.createClass({ submitting: true, }); lbryio.call('user_email', 'new', {email: this.state.email}, 'post').then(() => { - this.props.onEmailSaved(this.state.email); + this.onEmailSaved(this.state.email); }, (error) => { if (error.xhr && error.xhr.status == 409) { - this.props.onEmailSaved(this.state.email); + this.onEmailSaved(this.state.email); return; } else if (this._emailRow) { this._emailRow.showError(error.message) @@ -85,7 +87,7 @@ const ConfirmEmailStage = React.createClass({ lbryio.call('user_email', 'confirm', {verification_token: this.state.code, email: this.props.email}, 'post').then((userEmail) => { if (userEmail.IsVerified) { - this.props.onEmailConfirmed(); + this.props.setStage("welcome") } else { onSubmitError(new Error("Your email is still not verified.")) //shouldn't happen? } @@ -98,9 +100,12 @@ const ConfirmEmailStage = React.createClass({ { this._codeRow = ref }} type="text" name="code" placeholder="a94bXXXXXXXXXXXXXX" value={this.state.code} onChange={this.handleCodeChanged} helper="A verification code is required to access this version."/> -
+
+
+ No code? { this.props.setStage("nocode")}} label="Click here" />. +
); @@ -176,10 +181,66 @@ const PendingStage = React.createClass({ } }); + +const CodeRequiredStage = React.createClass({ + _balanceSubscribeId: null, + getInitialState: function() { + return { + balance: 0, + address: getLocal('wallet_address') + } + }, + + componentWillMount: function() { + this._balanceSubscribeId = lbry.balanceSubscribe((balance) => { + this.setState({ + balance: balance + }); + }) + + if (!this.state.address) { + lbry.call('wallet_new_address', {}, (address) => { + setLocal('wallet_address', address); + this.setState({ address: address }); + }); + } + }, + componentWillUnmount: function() { + if (this._balanceSubscribeId) { + lbry.balanceUnsubscribe(this._balanceSubscribeId) + } + }, + render: function() { + const disabled = this.state.balance < 1; + return ( +
+
+

Access to LBRY is restricted as we build and scale the network.

+

There are two ways in:

+

Own LBRY Credits

+

If you own at least 1 LBC, you can get in right now.

+

{ setLocal('auth_bypassed', true); this.props.setStage(null); }} + disabled={disabled} label="Let Me In" button={ disabled ? "alt" : "primary" } />

+

Your balance is . To increase your balance, send credits to this address:

+

+

If you don't understand how to send credits, then...

+
+
+

Wait For A Code

+

If you provide your email, you'll automatically receive a notification when the system is open.

+

{ this.props.setStage("email"); }} label="Return" />

+
+
+ ); + } +}); + + export const AuthOverlay = React.createClass({ _stages: { pending: PendingStage, error: ErrorStage, + nocode: CodeRequiredStage, email: SubmitEmailStage, confirm: ConfirmEmailStage, welcome: WelcomeStage @@ -190,42 +251,31 @@ export const AuthOverlay = React.createClass({ stageProps: {} }; }, - endAuth: function() { + setStage: function(stage, stageProps = {}) { this.setState({ - stage: null - }); + stage: stage, + stageProps: stageProps + }) }, componentWillMount: function() { - lbryio.authenticate().then(function(user) { - if (!user.HasVerifiedEmail) { //oops I fucked this up - this.setState({ - stage: "email", - stageProps: { - onEmailSaved: function(email) { - this.setState({ - stage: "confirm", - stageProps: { - email: email, - onEmailConfirmed: function() { this.setState({ stage: "welcome"}) }.bind(this) - } - }) - }.bind(this) - } - }) + lbryio.authenticate().then((user) => { + if (!user.HasVerifiedEmail) { + if (getLocal('auth_bypassed')) { + this.setStage(null) + } else { + this.setStage("email", {}) + } } else { - lbryio.call('reward', 'list', {}).then(function(userRewards) { + lbryio.call('reward', 'list', {}).then((userRewards) => { userRewards.filter(function(reward) { return reward.RewardType == "new_user" && reward.TransactionID; }).length ? - this.endAuth() : - this.setState({ stage: "welcome" }) - }.bind(this)); + this.setStage(null) : + this.setStage("welcome") + }); } - }.bind(this)).catch((err) => { - this.setState({ - stage: "error", - stageProps: { errorText: err.message } - }) + }).catch((err) => { + this.setStage("error", { errorText: err.message }) document.dispatchEvent(new CustomEvent('unhandledError', { detail: { message: err.message, @@ -243,9 +293,9 @@ export const AuthOverlay = React.createClass({ this.state.stage != "welcome" ?

LBRY Early Access

- +
: - + ); } }); \ No newline at end of file diff --git a/ui/js/component/common.js b/ui/js/component/common.js index 0c8d66ca0..7139e5dfe 100644 --- a/ui/js/component/common.js +++ b/ui/js/component/common.js @@ -149,12 +149,14 @@ var addressStyle = { fontFamily: '"Consolas", "Lucida Console", "Adobe Source Code Pro", monospace', }; export let Address = React.createClass({ + _inputElem: null, propTypes: { address: React.PropTypes.string, }, render: function() { return ( - {this.props.address} + { this._inputElem = input; }} + onFocus={() => { this._inputElem.select(); }} style={addressStyle} readOnly="readonly" value={this.props.address}> ); } }); diff --git a/ui/js/lbryio.js b/ui/js/lbryio.js index 504b6b3e4..bbe6b9ccd 100644 --- a/ui/js/lbryio.js +++ b/ui/js/lbryio.js @@ -7,10 +7,10 @@ const lbryio = { _accessToken: getLocal('accessToken'), _authenticationPromise: null, _user : null, - enabled: false + enabled: true }; -const CONNECTION_STRING = 'https://api.lbry.io/'; +const CONNECTION_STRING = process.env.LBRY_APP_API_URL ? process.env.LBRY_APP_API_URL : 'https://api.lbry.io/'; const EXCHANGE_RATE_TIMEOUT = 20 * 60 * 1000; lbryio.getExchangeRates = function() { diff --git a/ui/scss/_gui.scss b/ui/scss/_gui.scss index da32d3ac5..f875a6940 100644 --- a/ui/scss/_gui.scss +++ b/ui/scss/_gui.scss @@ -38,20 +38,6 @@ text-align: center; } -/* -section -{ - margin-bottom: $spacing-vertical; - &:last-child - { - margin-bottom: 0; - } - &:only-child { - margin-bottom: $spacing-vertical; - } -} -*/ - h2 { font-size: 1.75em; } @@ -147,3 +133,7 @@ p font-size: 0.85em; color: $color-help; } + +section.section-spaced { + margin-bottom: $spacing-vertical; +} diff --git a/ui/scss/component/_form-field.scss b/ui/scss/component/_form-field.scss index c9f00b141..fa2b36e27 100644 --- a/ui/scss/component/_form-field.scss +++ b/ui/scss/component/_form-field.scss @@ -1,11 +1,16 @@ @import "../global"; $width-input-border: 2px; +$width-input-text: 330px; .form-row-submit { margin-top: $spacing-vertical; } +.form-row-submit--with-footer +{ + margin-bottom: $spacing-vertical; +} .form-row__label-row { margin-top: $spacing-vertical * 5/6; @@ -18,6 +23,18 @@ $width-input-border: 2px; margin-right: 5px; } +input[type="text"].input-copyable { + border: 1px solid $color-form-border; + line-height: 1; + padding-top: $spacing-vertical * 1/3; + padding-bottom: $spacing-vertical * 1/3; + width: $width-input-text; + padding-left: 5px; + padding-right: 5px; + width: 100%; + &:focus { border-color: black; } +} + .form-field { display: inline-block; @@ -66,7 +83,7 @@ $width-input-border: 2px; input[type="search"], input[type="date"] { border-bottom: $width-input-border solid $color-form-border; - line-height: 1px; + line-height: 1; padding-top: $spacing-vertical * 1/3; padding-bottom: $spacing-vertical * 1/3; &.form-field__input--error { @@ -108,7 +125,7 @@ $width-input-border: 2px; } .form-field__input-text { - width: 330px; + width: $width-input-text; } .form-field__prefix { @@ -124,7 +141,7 @@ $width-input-border: 2px; } .form-field__input-textarea { - width: 330px; + width: $width-input-text; } .form-field__error, .form-field__helper { diff --git a/ui/scss/component/_modal-page.scss b/ui/scss/component/_modal-page.scss index d9bd0d8d5..ada366f61 100644 --- a/ui/scss/component/_modal-page.scss +++ b/ui/scss/component/_modal-page.scss @@ -17,6 +17,9 @@ right: 0; top: 0; bottom: 0; + .modal-page__content { + max-width: 500px; + } } /* diff --git a/ui/webpack.config.js b/ui/webpack.config.js index fdafd70b2..be349baa9 100644 --- a/ui/webpack.config.js +++ b/ui/webpack.config.js @@ -35,4 +35,4 @@ module.exports = { ] }, target: 'electron-main', -}; +}; \ No newline at end of file diff --git a/ui/webpack.dev.config.js b/ui/webpack.dev.config.js index b84f2f94a..358d6c04d 100644 --- a/ui/webpack.dev.config.js +++ b/ui/webpack.dev.config.js @@ -38,4 +38,4 @@ module.exports = { ] }, target: 'electron-main', -}; +}; \ No newline at end of file