diff --git a/ui/js/actions/app.js b/ui/js/actions/app.js
index d812172b6..309e21b01 100644
--- a/ui/js/actions/app.js
+++ b/ui/js/actions/app.js
@@ -8,13 +8,11 @@ import {
selectPageTitle,
selectCurrentPage,
selectCurrentParams,
- selectWelcomeModalAcknowledged,
} from "selectors/app";
import { doSearch } from "actions/search";
import { doFetchDaemonSettings } from "actions/settings";
import { doAuthenticate } from "actions/user";
import { doFileList } from "actions/file_info";
-import * as modals from "constants/modal_types";
const { remote, ipcRenderer, shell } = require("electron");
const path = require("path");
@@ -220,17 +218,13 @@ export function doAlertError(errorList) {
}
export function doDaemonReady() {
- return function(dispatch, getState) {
- const showWelcome = !selectWelcomeModalAcknowledged(getState());
+ return function(dispatch) {
dispatch(doAuthenticate());
dispatch({
type: types.DAEMON_READY,
});
dispatch(doFetchDaemonSettings());
dispatch(doFileList());
- if (showWelcome) {
- dispatch(doOpenModal(modals.WELCOME));
- }
};
}
diff --git a/ui/js/component/app/index.js b/ui/js/component/app/index.js
index 4c966cb56..0d4e1c093 100644
--- a/ui/js/component/app/index.js
+++ b/ui/js/component/app/index.js
@@ -1,18 +1,40 @@
import React from "react";
import { connect } from "react-redux";
-
import { selectCurrentModal } from "selectors/app";
-import { doCheckUpgradeAvailable, doAlertError } from "actions/app";
+import {
+ doCheckUpgradeAvailable,
+ doOpenModal,
+ doAlertError,
+} from "actions/app";
import { doUpdateBalance } from "actions/wallet";
+import { selectWelcomeModalAcknowledged } from "selectors/app";
+import rewards from "rewards";
+import {
+ selectFetchingRewards,
+ makeSelectHasClaimedReward,
+} from "selectors/rewards";
+import { selectUser } from "selectors/user";
import App from "./view";
+import * as modals from "constants/modal_types";
-const select = state => ({
- modal: selectCurrentModal(state),
-});
+const select = (state, props) => {
+ const selectHasClaimed = makeSelectHasClaimedReward();
+
+ return {
+ modal: selectCurrentModal(state),
+ isWelcomeAcknowledged: selectWelcomeModalAcknowledged(state),
+ isFetchingRewards: selectFetchingRewards(state),
+ isWelcomeRewardClaimed: selectHasClaimed(state, {
+ reward_type: rewards.TYPE_NEW_USER,
+ }),
+ user: selectUser(state),
+ };
+};
const perform = dispatch => ({
alertError: errorList => dispatch(doAlertError(errorList)),
checkUpgradeAvailable: () => dispatch(doCheckUpgradeAvailable()),
+ openWelcomeModal: () => dispatch(doOpenModal(modals.WELCOME)),
updateBalance: balance => dispatch(doUpdateBalance(balance)),
});
diff --git a/ui/js/component/app/view.jsx b/ui/js/component/app/view.jsx
index 8f4c54cb0..7c6b17eca 100644
--- a/ui/js/component/app/view.jsx
+++ b/ui/js/component/app/view.jsx
@@ -11,17 +11,43 @@ import * as modals from "constants/modal_types";
class App extends React.PureComponent {
componentWillMount() {
+ const { alertError, checkUpgradeAvailable, updateBalance } = this.props;
+
document.addEventListener("unhandledError", event => {
- this.props.alertError(event.detail);
+ alertError(event.detail);
});
if (!this.props.upgradeSkipped) {
- this.props.checkUpgradeAvailable();
+ checkUpgradeAvailable();
}
lbry.balanceSubscribe(balance => {
- this.props.updateBalance(balance);
+ updateBalance(balance);
});
+
+ this.showWelcome(this.props);
+ }
+
+ componentWillReceiveProps(nextProps) {
+ this.showWelcome(nextProps);
+ }
+
+ showWelcome(props) {
+ const {
+ isFetchingRewards,
+ isWelcomeAcknowledged,
+ isWelcomeRewardClaimed,
+ openWelcomeModal,
+ user,
+ } = props;
+
+ if (
+ !isWelcomeAcknowledged &&
+ user &&
+ (!isFetchingRewards || !isWelcomeRewardClaimed)
+ ) {
+ openWelcomeModal();
+ }
}
render() {
diff --git a/ui/js/component/auth/index.js b/ui/js/component/auth/index.js
index 37af9f90f..f448d6e82 100644
--- a/ui/js/component/auth/index.js
+++ b/ui/js/component/auth/index.js
@@ -4,12 +4,14 @@ import {
selectAuthenticationIsPending,
selectEmailToVerify,
selectUserIsVerificationCandidate,
+ selectUser,
} from "selectors/user";
import Auth from "./view";
const select = state => ({
isPending: selectAuthenticationIsPending(state),
email: selectEmailToVerify(state),
+ user: selectUser(state),
isVerificationCandidate: selectUserIsVerificationCandidate(state),
});
diff --git a/ui/js/component/auth/view.jsx b/ui/js/component/auth/view.jsx
index 551113ffa..1c49c513f 100644
--- a/ui/js/component/auth/view.jsx
+++ b/ui/js/component/auth/view.jsx
@@ -2,17 +2,20 @@ import React from "react";
import { BusyMessage } from "component/common";
import UserEmailNew from "component/userEmailNew";
import UserEmailVerify from "component/userEmailVerify";
+import UserVerify from "component/userVerify";
export class Auth extends React.PureComponent {
render() {
- const { isPending, email, isVerificationCandidate } = this.props;
+ const { email, isPending, isVerificationCandidate, user } = this.props;
if (isPending) {
return
{__( "If you continue without an email, you will be ineligible to earn free LBC rewards, as well as unable to receive security related communications." diff --git a/ui/js/component/common.js b/ui/js/component/common.js index 38dbf83fd..8e7279248 100644 --- a/ui/js/component/common.js +++ b/ui/js/component/common.js @@ -1,4 +1,5 @@ import React from "react"; +import { formatCredits } from "utils"; import lbry from "../lbry.js"; //component/icon.js @@ -78,7 +79,7 @@ export class CreditAmount extends React.PureComponent { }; render() { - const formattedAmount = lbry.formatCredits( + const formattedAmount = formatCredits( this.props.amount, this.props.precision ); @@ -140,7 +141,7 @@ export class Address extends React.PureComponent { }} style={addressStyle} readOnly="readonly" - value={this.props.address} + value={this.props.address || ""} /> ); } diff --git a/ui/js/component/header/index.js b/ui/js/component/header/index.js index d05e7800b..eda8923d3 100644 --- a/ui/js/component/header/index.js +++ b/ui/js/component/header/index.js @@ -1,12 +1,12 @@ import React from "react"; -import lbry from "lbry"; +import { formatCredits } from "utils"; import { connect } from "react-redux"; import { selectBalance } from "selectors/wallet"; import { doNavigate, doHistoryBack } from "actions/app"; import Header from "./view"; const select = state => ({ - balance: lbry.formatCredits(selectBalance(state), 1), + balance: formatCredits(selectBalance(state), 1), publish: __("Publish"), }); diff --git a/ui/js/component/modalWelcome/view.jsx b/ui/js/component/modalWelcome/view.jsx index cfd3d2c67..3dec74cfa 100644 --- a/ui/js/component/modalWelcome/view.jsx +++ b/ui/js/component/modalWelcome/view.jsx @@ -31,8 +31,11 @@ class ModalWelcome extends React.PureComponent { )}
- {__("Thank you for making content freedom possible!")}
- {" "}{isRewardApproved ? __("Here's a nickel, kid.") : ""}
+ {__("Please have")} {" "}
+ {reward &&
+
- {__( - "Additional information is required to be eligible for the rewards program." - )} -
-+ {" "}{__( + "Claim your welcome credits to be able to publish content, pay creators, and have a say over the LBRY network." + )} +
+{__("You are not eligible to claim rewards.")}