diff --git a/app/main.js b/app/main.js index 13bdbb2b9..70e9941a7 100644 --- a/app/main.js +++ b/app/main.js @@ -273,7 +273,7 @@ app.on('activate', () => { // then calls quitNow() to quit for real. function shutdownDaemonAndQuit(evenIfNotStartedByApp = false) { function doShutdown() { - console.log('Asking daemon to shut down down'); + console.log('Shutting down daemon'); daemonStopRequested = true; client.request('daemon_stop', [], (err, res) => { if (err) { diff --git a/ui/js/component/auth.js b/ui/js/component/auth.js index dc36367be..2e62e5816 100644 --- a/ui/js/component/auth.js +++ b/ui/js/component/auth.js @@ -5,7 +5,8 @@ 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'; +import {getLocal, setLocal} from '../utils.js'; +import {TYPE_NEW_USER} from '../rewards' const SubmitEmailStage = React.createClass({ @@ -86,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) { + if (userEmail.is_verified) { this.props.setStage("welcome") } else { onSubmitError(new Error("Your email is still not verified.")) //shouldn't happen? @@ -259,7 +260,7 @@ export const AuthOverlay = React.createClass({ }, componentWillMount: function() { lbryio.authenticate().then((user) => { - if (!user.HasVerifiedEmail) { + if (!user.has_verified_email) { if (getLocal('auth_bypassed')) { this.setStage(null) } else { @@ -268,7 +269,7 @@ export const AuthOverlay = React.createClass({ } else { lbryio.call('reward', 'list', {}).then((userRewards) => { userRewards.filter(function(reward) { - return reward.RewardType == "new_user" && reward.TransactionID; + return reward.reward_type == TYPE_NEW_USER && reward.transaction_id; }).length ? this.setStage(null) : this.setStage("welcome") diff --git a/ui/js/lbryio.js b/ui/js/lbryio.js index 20934bbbb..d7e3ca5c8 100644 --- a/ui/js/lbryio.js +++ b/ui/js/lbryio.js @@ -10,7 +10,9 @@ const lbryio = { enabled: false }; -const CONNECTION_STRING = process.env.LBRY_APP_API_URL ? process.env.LBRY_APP_API_URL : 'https://api.lbry.io/'; +const CONNECTION_STRING = process.env.LBRY_APP_API_URL ? + process.env.LBRY_APP_API_URL.replace(/\/*$/,'/') : // exactly one slash at the end + 'https://api.lbry.io/'; const EXCHANGE_RATE_TIMEOUT = 20 * 60 * 1000; lbryio.getExchangeRates = function() { @@ -34,6 +36,7 @@ lbryio.getExchangeRates = function() { lbryio.call = function(resource, action, params={}, method='get', evenIfDisabled=false) { // evenIfDisabled is just for development, when we may have some calls working and some not return new Promise((resolve, reject) => { if (!lbryio.enabled && !evenIfDisabled && (resource != 'discover' || action != 'list')) { + console.log("Internal API disabled"); reject(new Error("LBRY internal API is disabled")) return } @@ -87,6 +90,8 @@ lbryio.call = function(resource, action, params={}, method='get', evenIfDisabled xhr.open('post', CONNECTION_STRING + resource + '/' + action, true); xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); xhr.send(querystring.stringify(fullParams)); + } else { + reject(new Error("Invalid method")); } }); }; @@ -103,8 +108,8 @@ lbryio.authenticate = function() { if (!lbryio.enabled) { return new Promise((resolve, reject) => { resolve({ - ID: 1, - HasVerifiedEmail: true + id: 1, + has_verified_email: true }) }) } @@ -134,7 +139,7 @@ lbryio.authenticate = function() { language: 'en', app_id: installation_id, }, 'post').then(function(responseData) { - if (!responseData.ID) { + if (!responseData.id) { reject(new Error("Received invalid authentication response.")); } lbryio.setAccessToken(installation_id) diff --git a/ui/js/page/file-list.js b/ui/js/page/file-list.js index 71f8e2fc2..a21662b01 100644 --- a/ui/js/page/file-list.js +++ b/ui/js/page/file-list.js @@ -76,7 +76,7 @@ export let FileListPublished = React.createClass({ lbryio.call('reward', 'list', {}).then(function(userRewards) { //already rewarded if (userRewards.filter(function (reward) { - return reward.RewardType == rewards.TYPE_FIRST_PUBLISH && reward.TransactionID; + return reward.reward_type == rewards.TYPE_FIRST_PUBLISH && reward.transaction_id; }).length) { return; } diff --git a/ui/js/page/rewards.js b/ui/js/page/rewards.js index 3462517c9..bbe04af80 100644 --- a/ui/js/page/rewards.js +++ b/ui/js/page/rewards.js @@ -47,7 +47,7 @@ var RewardsPage = React.createClass({ }; }, loadRewards: function() { - lbryio.call('reward', 'list', {}).then((userRewards) => { + lbryio.call('reward', 'list').then((userRewards) => { this.setState({ userRewards: userRewards, }); @@ -62,8 +62,8 @@ var RewardsPage = React.createClass({ <div> {!this.state.userRewards ? (this.state.failed ? <div className="empty">Failed to load rewards.</div> : '') - : this.state.userRewards.map(({RewardType, RewardTitle, RewardDescription, TransactionID, RewardAmount}) => { - return <RewardTile key={RewardType} onRewardClaim={this.loadRewards} type={RewardType} title={RewardTitle} description={RewardDescription} claimed={!!TransactionID} value={RewardAmount} />; + : this.state.userRewards.map(({reward_type, reward_title, reward_description, transaction_id, reward_amount}) => { + return <RewardTile key={reward_type} onRewardClaim={this.loadRewards} type={reward_type} title={reward_title} description={reward_description} claimed={!!transaction_id} value={reward_amount} />; })} </div> </main> diff --git a/ui/js/page/search.js b/ui/js/page/search.js index dafeb30cf..ff18bd2ed 100644 --- a/ui/js/page/search.js +++ b/ui/js/page/search.js @@ -12,7 +12,7 @@ var SearchNoResults = React.createClass({ render: function() { return <section> <span className="empty"> - No one has checked anything in for {this.props.query} yet. + No one has checked anything in for {this.props.query} yet. <Link label="Be the first" href="?publish" /> </span> </section>; diff --git a/ui/js/rewards.js b/ui/js/rewards.js index 399965db2..128bc33e6 100644 --- a/ui/js/rewards.js +++ b/ui/js/rewards.js @@ -16,12 +16,12 @@ function rewardMessage(type, amount) { const rewards = {}; rewards.TYPE_NEW_DEVELOPER = "new_developer", - rewards.TYPE_NEW_USER = "new_user", - rewards.TYPE_CONFIRM_EMAIL = "confirm_email", - rewards.TYPE_FIRST_CHANNEL = "new_channel", - rewards.TYPE_FIRST_STREAM = "first_stream", - rewards.TYPE_MANY_DOWNLOADS = "many_downloads", - rewards.TYPE_FIRST_PUBLISH = "first_publish"; +rewards.TYPE_NEW_USER = "new_user", +rewards.TYPE_CONFIRM_EMAIL = "confirm_email", +rewards.TYPE_FIRST_CHANNEL = "new_channel", +rewards.TYPE_FIRST_STREAM = "first_stream", +rewards.TYPE_MANY_DOWNLOADS = "many_downloads", +rewards.TYPE_FIRST_PUBLISH = "first_publish"; rewards.claimReward = function (type) { @@ -30,12 +30,12 @@ rewards.claimReward = function (type) { reject(new Error("Rewards are not enabled.")) return; } - lbryio.call('reward', 'new', params, 'post').then(({RewardAmount}) => { + lbryio.call('reward', 'new', params, 'post').then(({reward_amount}) => { const - message = rewardMessage(type, RewardAmount), + message = rewardMessage(type, reward_amount), result = { type: type, - amount: RewardAmount, + amount: reward_amount, message: message }; @@ -108,8 +108,8 @@ rewards.claimNextPurchaseReward = function() { types[rewards.TYPE_MANY_DOWNLOADS] = false lbryio.call('reward', 'list', {}).then((userRewards) => { userRewards.forEach((reward) => { - if (types[reward.RewardType] === false && reward.TransactionID) { - types[reward.RewardType] = true + if (types[reward.reward_type] === false && reward.transaction_id) { + types[reward.reward_type] = true } }) let unclaimedType = Object.keys(types).find((type) => {