Merge branch 'issue/708'

This commit is contained in:
Igor Gassmann 2017-11-21 16:51:55 -03:00
commit b8333db3bc
19 changed files with 341 additions and 262 deletions

View file

@ -6,9 +6,8 @@ import {
selectActiveHistoryEntry, selectActiveHistoryEntry,
} from "redux/selectors/navigation"; } from "redux/selectors/navigation";
import { selectUser } from "redux/selectors/user"; import { selectUser } from "redux/selectors/user";
import { doCheckUpgradeAvailable, doAlertError } from "redux/actions/app"; import { doAlertError } from "redux/actions/app";
import { doRecordScroll } from "redux/actions/navigation"; import { doRecordScroll } from "redux/actions/navigation";
import { doFetchRewardedContent } from "redux/actions/content";
import App from "./view"; import App from "./view";
const select = (state, props) => ({ const select = (state, props) => ({
@ -20,8 +19,6 @@ const select = (state, props) => ({
const perform = dispatch => ({ const perform = dispatch => ({
alertError: errorList => dispatch(doAlertError(errorList)), alertError: errorList => dispatch(doAlertError(errorList)),
checkUpgradeAvailable: () => dispatch(doCheckUpgradeAvailable()),
fetchRewardedContent: () => dispatch(doFetchRewardedContent()),
recordScroll: scrollPosition => dispatch(doRecordScroll(scrollPosition)), recordScroll: scrollPosition => dispatch(doRecordScroll(scrollPosition)),
}); });

View file

@ -13,23 +13,11 @@ class App extends React.PureComponent {
} }
componentWillMount() { componentWillMount() {
const { const { alertError } = this.props;
alertError,
checkUpgradeAvailable,
fetchRewardedContent,
} = this.props;
document.addEventListener("unhandledError", event => { document.addEventListener("unhandledError", event => {
alertError(event.detail); alertError(event.detail);
}); });
if (!this.props.upgradeSkipped) {
checkUpgradeAvailable();
}
fetchRewardedContent();
this.setTitleFromProps(this.props);
} }
componentDidMount() { componentDidMount() {

View file

@ -5,9 +5,10 @@ import { doFetchBlock } from "redux/actions/wallet";
import DateTime from "./view"; import DateTime from "./view";
const select = (state, props) => ({ const select = (state, props) => ({
date: !props.date && props.block date:
? makeSelectBlockDate(props.block)(state) !props.date && props.block
: props.date, ? makeSelectBlockDate(props.block)(state)
: props.date,
}); });
const perform = dispatch => ({ const perform = dispatch => ({

View file

@ -12,18 +12,21 @@ import {
doHistoryForward, doHistoryForward,
} from "redux/actions/navigation"; } from "redux/actions/navigation";
import Header from "./view"; import Header from "./view";
import { selectIsUpgradeAvailable } from "../../selectors/app";
import { doDownloadUpgrade } from "../../actions/app";
const select = state => ({ const select = state => ({
isBackDisabled: selectIsBackDisabled(state), isBackDisabled: selectIsBackDisabled(state),
isForwardDisabled: selectIsForwardDisabled(state), isForwardDisabled: selectIsForwardDisabled(state),
isUpgradeAvailable: selectIsUpgradeAvailable(state),
balance: formatCredits(selectBalance(state) || 0, 1), balance: formatCredits(selectBalance(state) || 0, 1),
publish: __("Publish"),
}); });
const perform = dispatch => ({ const perform = dispatch => ({
navigate: path => dispatch(doNavigate(path)), navigate: path => dispatch(doNavigate(path)),
back: () => dispatch(doHistoryBack()), back: () => dispatch(doHistoryBack()),
forward: () => dispatch(doHistoryForward()), forward: () => dispatch(doHistoryForward()),
downloadUpgrade: () => dispatch(doDownloadUpgrade()),
}); });
export default connect(select, perform)(Header); export default connect(select, perform)(Header);

View file

@ -9,8 +9,9 @@ export const Header = props => {
forward, forward,
isBackDisabled, isBackDisabled,
isForwardDisabled, isForwardDisabled,
isUpgradeAvailable,
navigate, navigate,
publish, downloadUpgrade,
} = props; } = props;
return ( return (
<header id="header"> <header id="header">
@ -58,7 +59,7 @@ export const Header = props => {
onClick={() => navigate("/publish")} onClick={() => navigate("/publish")}
button="primary button--flat" button="primary button--flat"
icon="icon-upload" icon="icon-upload"
label={publish} label={__("Publish")}
/> />
</div> </div>
<div className="header__item"> <div className="header__item">
@ -77,6 +78,14 @@ export const Header = props => {
title={__("Settings")} title={__("Settings")}
/> />
</div> </div>
{isUpgradeAvailable && (
<Link
onClick={() => downloadUpgrade()}
button="primary button--flat"
icon="icon-arrow-up"
label={__("Upgrade App")}
/>
)}
</header> </header>
); );
}; };

View file

@ -340,9 +340,10 @@ class PublishForm extends React.PureComponent {
handleFeePrefChange(feeEnabled) { handleFeePrefChange(feeEnabled) {
this.setState({ this.setState({
isFee: feeEnabled, isFee: feeEnabled,
feeAmount: this.state.feeAmount == "" feeAmount:
? this._defaultPaidPrice this.state.feeAmount == ""
: this.state.feeAmount, ? this._defaultPaidPrice
: this.state.feeAmount,
}); });
} }
@ -556,82 +557,82 @@ class PublishForm extends React.PureComponent {
} }
/> />
</div> </div>
{!this.state.hasFile && !this.myClaimExists() {!this.state.hasFile && !this.myClaimExists() ? null : (
? null <div>
: <div> <div className="card__content">
<div className="card__content"> <FormRow
<FormRow ref="meta_title"
ref="meta_title" label={__("Title")}
label={__("Title")} type="text"
type="text" name="title"
name="title" value={this.state.meta_title}
value={this.state.meta_title} placeholder="Titular Title"
placeholder="Titular Title" onChange={event => {
onChange={event => { this.handleMetadataChange(event);
this.handleMetadataChange(event); }}
}} />
/> </div>
</div> <div className="card__content">
<div className="card__content"> <FormRow
<FormRow type="text"
type="text" label={__("Thumbnail URL")}
label={__("Thumbnail URL")} name="thumbnail"
name="thumbnail" value={this.state.meta_thumbnail}
value={this.state.meta_thumbnail} placeholder="http://spee.ch/mylogo"
placeholder="http://spee.ch/mylogo" onChange={event => {
onChange={event => { this.handleMetadataChange(event);
this.handleMetadataChange(event); }}
}} />
/> </div>
</div> <div className="card__content">
<div className="card__content"> <FormRow
<FormRow type="SimpleMDE"
type="SimpleMDE" label={__("Description")}
label={__("Description")} ref="meta_description"
ref="meta_description" name="description"
name="description" value={this.state.meta_description}
value={this.state.meta_description} placeholder={__("Description of your content")}
placeholder={__("Description of your content")} onChange={text => {
onChange={text => { this.handleDescriptionChanged(text);
this.handleDescriptionChanged(text); }}
}} />
/> </div>
</div> <div className="card__content">
<div className="card__content"> <FormRow
<FormRow label={__("Language")}
label={__("Language")} type="select"
type="select" value={this.state.meta_language}
value={this.state.meta_language} name="language"
name="language" onChange={event => {
onChange={event => { this.handleMetadataChange(event);
this.handleMetadataChange(event); }}
}} >
> <option value="en">{__("English")}</option>
<option value="en">{__("English")}</option> <option value="zh">{__("Chinese")}</option>
<option value="zh">{__("Chinese")}</option> <option value="fr">{__("French")}</option>
<option value="fr">{__("French")}</option> <option value="de">{__("German")}</option>
<option value="de">{__("German")}</option> <option value="jp">{__("Japanese")}</option>
<option value="jp">{__("Japanese")}</option> <option value="ru">{__("Russian")}</option>
<option value="ru">{__("Russian")}</option> <option value="es">{__("Spanish")}</option>
<option value="es">{__("Spanish")}</option> </FormRow>
</FormRow> </div>
</div> <div className="card__content">
<div className="card__content"> <FormRow
<FormRow type="select"
type="select" label={__("Maturity")}
label={__("Maturity")} value={this.state.meta_nsfw}
value={this.state.meta_nsfw} name="nsfw"
name="nsfw" onChange={event => {
onChange={event => { this.handleMetadataChange(event);
this.handleMetadataChange(event); }}
}} >
> {/* <option value=""></option> */}
{/* <option value=""></option> */} <option value="0">{__("All Ages")}</option>
<option value="0">{__("All Ages")}</option> <option value="1">{__("Adults Only")}</option>
<option value="1">{__("Adults Only")}</option> </FormRow>
</FormRow> </div>
</div> </div>
</div>} )}
</section> </section>
<section className="card"> <section className="card">
@ -668,13 +669,14 @@ class PublishForm extends React.PureComponent {
onChange={val => this.handleFeeChange(val)} onChange={val => this.handleFeeChange(val)}
/> />
</span> </span>
{this.state.isFee && this.state.feeCurrency.toUpperCase() != "LBC" {this.state.isFee &&
? <div className="form-field__helper"> this.state.feeCurrency.toUpperCase() != "LBC" ? (
{__( <div className="form-field__helper">
"All content fees are charged in LBC. For non-LBC payment methods, the number of credits charged will be adjusted based on the value of LBRY credits at the time of purchase." {__(
)} "All content fees are charged in LBC. For non-LBC payment methods, the number of credits charged will be adjusted based on the value of LBRY credits at the time of purchase."
</div> )}
: null} </div>
) : null}
</div> </div>
</section> </section>
<section className="card"> <section className="card">
@ -740,49 +742,45 @@ class PublishForm extends React.PureComponent {
"Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International" "Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International"
)} )}
</option> </option>
<option value="copyright"> <option value="copyright">{__("Copyrighted...")}</option>
{__("Copyrighted...")} <option value="other">{__("Other...")}</option>
</option>
<option value="other">
{__("Other...")}
</option>
</FormRow> </FormRow>
{this.state.licenseType == "copyright" {this.state.licenseType == "copyright" ? (
? <FormRow <FormRow
label={__("Copyright notice")} label={__("Copyright notice")}
type="text" type="text"
name="copyright-notice" name="copyright-notice"
value={this.state.copyrightNotice} value={this.state.copyrightNotice}
onChange={event => { onChange={event => {
this.handleCopyrightNoticeChange(event); this.handleCopyrightNoticeChange(event);
}} }}
/> />
: null} ) : null}
{this.state.licenseType == "other" {this.state.licenseType == "other" ? (
? <FormRow <FormRow
label={__("License description")} label={__("License description")}
type="text" type="text"
name="other-license-description" name="other-license-description"
value={this.state.otherLicenseDescription} value={this.state.otherLicenseDescription}
onChange={event => { onChange={event => {
this.handleOtherLicenseDescriptionChange(event); this.handleOtherLicenseDescriptionChange(event);
}} }}
/> />
: null} ) : null}
{this.state.licenseType == "other" {this.state.licenseType == "other" ? (
? <FormRow <FormRow
label={__("License URL")} label={__("License URL")}
type="text" type="text"
name="other-license-url" name="other-license-url"
value={this.state.otherLicenseUrl} value={this.state.otherLicenseUrl}
onChange={event => { onChange={event => {
this.handleOtherLicenseUrlChange(event); this.handleOtherLicenseUrlChange(event);
}} }}
/> />
: null} ) : null}
</div> </div>
</section> </section>
@ -798,8 +796,7 @@ class PublishForm extends React.PureComponent {
<div className="card__subtitle"> <div className="card__subtitle">
{__( {__(
"This is the exact address where people find your content (ex. lbry://myvideo)." "This is the exact address where people find your content (ex. lbry://myvideo)."
)} )}{" "}
{" "}
<Link <Link
label={__("Learn more")} label={__("Learn more")}
href="https://lbry.io/faq/naming" href="https://lbry.io/faq/naming"
@ -808,9 +805,11 @@ class PublishForm extends React.PureComponent {
</div> </div>
<div className="card__content"> <div className="card__content">
<FormRow <FormRow
prefix={`lbry://${this.state.channel === "anonymous" prefix={`lbry://${
? "" this.state.channel === "anonymous"
: `${this.state.channel}/`}`} ? ""
: `${this.state.channel}/`
}`}
type="text" type="text"
ref="name" ref="name"
placeholder="myname" placeholder="myname"
@ -821,24 +820,26 @@ class PublishForm extends React.PureComponent {
helper={this.getNameBidHelpText()} helper={this.getNameBidHelpText()}
/> />
</div> </div>
{this.state.rawName {this.state.rawName ? (
? <div className="card__content"> <div className="card__content">
<FormRow <FormRow
ref="bid" ref="bid"
type="number" type="number"
step="any" step="any"
label={__("Deposit")} label={__("Deposit")}
postfix="LBC" postfix="LBC"
onChange={event => { onChange={event => {
this.handleBidChange(event); this.handleBidChange(event);
}} }}
value={this.state.bid} value={this.state.bid}
placeholder={this.claim() ? this.topClaimValue() + 10 : 100} placeholder={this.claim() ? this.topClaimValue() + 10 : 100}
helper={lbcInputHelp} helper={lbcInputHelp}
min="0" min="0"
/> />
</div> </div>
: ""} ) : (
""
)}
</section> </section>
<section className="card"> <section className="card">
@ -850,8 +851,7 @@ class PublishForm extends React.PureComponent {
ref="tosAgree" ref="tosAgree"
label={ label={
<span> <span>
{__("I agree to the")} {__("I agree to the")}{" "}
{" "}
<Link <Link
href="https://www.lbry.io/termsofservice" href="https://www.lbry.io/termsofservice"
label={__("LBRY terms of service")} label={__("LBRY terms of service")}
@ -897,8 +897,8 @@ class PublishForm extends React.PureComponent {
}} }}
> >
<p> <p>
{__("Your file has been published to LBRY at the address")} {__("Your file has been published to LBRY at the address")}{" "}
{" "}<code>{this.state.uri}</code>! <code>{this.state.uri}</code>!
</p> </p>
<p> <p>
{__( {__(

View file

@ -60,13 +60,17 @@ class UriIndicator extends React.PureComponent {
const inner = ( const inner = (
<span> <span>
<span className="channel-name">{channelName}</span> {" "} <span className="channel-name">{channelName}</span>{" "}
{!signatureIsValid {!signatureIsValid ? (
? <Icon <Icon
icon={icon} icon={icon}
className={`channel-indicator__icon channel-indicator__icon--${modifier}`} className={`channel-indicator__icon channel-indicator__icon--${
/> modifier
: ""} }`}
/>
) : (
""
)}
</span> </span>
); );

View file

@ -20,7 +20,12 @@ export const UPGRADE_DOWNLOAD_STARTED = "UPGRADE_DOWNLOAD_STARTED";
export const UPGRADE_DOWNLOAD_COMPLETED = "UPGRADE_DOWNLOAD_COMPLETED"; export const UPGRADE_DOWNLOAD_COMPLETED = "UPGRADE_DOWNLOAD_COMPLETED";
export const UPGRADE_DOWNLOAD_PROGRESSED = "UPGRADE_DOWNLOAD_PROGRESSED"; export const UPGRADE_DOWNLOAD_PROGRESSED = "UPGRADE_DOWNLOAD_PROGRESSED";
export const CHECK_UPGRADE_AVAILABLE = "CHECK_UPGRADE_AVAILABLE"; export const CHECK_UPGRADE_AVAILABLE = "CHECK_UPGRADE_AVAILABLE";
export const CHECK_UPGRADE_START = "CHECK_UPGRADE_START";
export const CHECK_UPGRADE_SUCCESS = "CHECK_UPGRADE_SUCCESS";
export const CHECK_UPGRADE_FAIL = "CHECK_UPGRADE_FAIL";
export const CHECK_UPGRADE_SUBSCRIBE = "CHECK_UPGRADE_SUBSCRIBE";
export const UPDATE_VERSION = "UPDATE_VERSION"; export const UPDATE_VERSION = "UPDATE_VERSION";
export const UPDATE_REMOTE_VERSION = "UPDATE_REMOTE_VERSION";
export const SKIP_UPGRADE = "SKIP_UPGRADE"; export const SKIP_UPGRADE = "SKIP_UPGRADE";
export const START_UPGRADE = "START_UPGRADE"; export const START_UPGRADE = "START_UPGRADE";

View file

@ -27,7 +27,9 @@ jsonrpc.call = function(
function makeRequest(url, options) { function makeRequest(url, options) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
fetch(url, options).then(resolve).catch(reject); fetch(url, options)
.then(resolve)
.catch(reject);
if (timeout) { if (timeout) {
const e = new Error(__("Protocol request timed out")); const e = new Error(__("Protocol request timed out"));

View file

@ -71,7 +71,10 @@ var init = function() {
ReactDOM.render( ReactDOM.render(
<Provider store={store}> <Provider store={store}>
<div><App /><SnackBar /></div> <div>
<App />
<SnackBar />
</div>
</Provider>, </Provider>,
canvas canvas
); );

View file

@ -12,37 +12,41 @@ const ModalCreditIntro = props => {
<section> <section>
<h3 className="modal__header">{__("Blockchain 101")}</h3> <h3 className="modal__header">{__("Blockchain 101")}</h3>
<p> <p>
LBRY is controlled and powered by a blockchain asset called {" "} LBRY is controlled and powered by a blockchain asset called{" "}
<em><CurrencySymbol /></em>.{" "} <em>
<CurrencySymbol />{" "} <CurrencySymbol />
</em>. <CurrencySymbol />{" "}
{__( {__(
"is used to publish content, to have a say in the network rules, and to access paid content." "is used to publish content, to have a say in the network rules, and to access paid content."
)} )}
</p> </p>
{currentBalance <= 0 {currentBalance <= 0 ? (
? <div> <div>
<p> <p>
You currently have <CreditAmount amount={currentBalance} />, so You currently have <CreditAmount amount={currentBalance} />, so
the actions you can take are limited. the actions you can take are limited.
</p> </p>
<p> <p>
However, there are a variety of ways to get credits, including However, there are a variety of ways to get credits, including
more than {" "} more than{" "}
{totalRewardValue {totalRewardValue ? (
? <CreditAmount amount={totalRewardRounded} /> <CreditAmount amount={totalRewardRounded} />
: <span className="credit-amount">{__("?? credits")}</span>} ) : (
{" "}{" "} <span className="credit-amount">{__("?? credits")}</span>
{__( )}{" "}
" in rewards available for being a proven human during the LBRY beta." {__(
)} " in rewards available for being a proven human during the LBRY beta."
</p> )}
</div> </p>
: <div> </div>
<p> ) : (
But you probably knew this, since you've already got{" "} <div>
<CreditAmount amount={currentBalance} />. <p>
</p> But you probably knew this, since you've already got{" "}
</div>} <CreditAmount amount={currentBalance} />.
</p>
</div>
)}
<div className="modal__buttons"> <div className="modal__buttons">
<Link <Link

View file

@ -15,8 +15,8 @@ import AuthPage from "./view";
const select = state => ({ const select = state => ({
isPending: isPending:
selectAuthenticationIsPending(state) || selectAuthenticationIsPending(state) ||
selectUserIsPending(state) || selectUserIsPending(state) ||
selectIdentityVerifyIsPending(state), selectIdentityVerifyIsPending(state),
email: selectEmailToVerify(state), email: selectEmailToVerify(state),
pathAfterAuth: selectPathAfterAuth(state), pathAfterAuth: selectPathAfterAuth(state),
user: selectUser(state), user: selectUser(state),

View file

@ -86,8 +86,7 @@ class ReportPage extends React.Component {
<section className="card"> <section className="card">
<div className="card__content"> <div className="card__content">
<h3>{__("Developer?")}</h3> <h3>{__("Developer?")}</h3>
{__("You can also")} {__("You can also")}{" "}
{" "}
<Link <Link
href="https://github.com/lbryio/lbry/issues" href="https://github.com/lbryio/lbry/issues"
label={__("submit an issue on GitHub")} label={__("submit an issue on GitHub")}

View file

@ -5,18 +5,23 @@ import {
selectUpgradeDownloadPath, selectUpgradeDownloadPath,
selectUpgradeDownloadItem, selectUpgradeDownloadItem,
selectUpgradeFilename, selectUpgradeFilename,
selectIsUpgradeSkipped,
selectRemoteVersion,
} from "redux/selectors/app"; } from "redux/selectors/app";
import { doFetchDaemonSettings } from "redux/actions/settings"; import { doFetchDaemonSettings } from "redux/actions/settings";
import { doBalanceSubscribe } from "redux/actions/wallet"; import { doBalanceSubscribe } from "redux/actions/wallet";
import { doAuthenticate } from "redux/actions/user"; import { doAuthenticate } from "redux/actions/user";
import { doFetchFileInfosAndPublishedClaims } from "redux/actions/file_info"; import { doFetchFileInfosAndPublishedClaims } from "redux/actions/file_info";
import * as modals from "constants/modal_types"; import * as modals from "constants/modal_types";
import { doFetchRewardedContent } from "actions/content";
import { selectCurrentModal } from "../selectors/app";
const { remote, ipcRenderer, shell } = require("electron"); const { remote, ipcRenderer, shell } = require("electron");
const path = require("path"); const path = require("path");
const { download } = remote.require("electron-dl"); const { download } = remote.require("electron-dl");
const fs = remote.require("fs"); const fs = remote.require("fs");
const { lbrySettings: config } = require("../../../../app/package.json"); const { lbrySettings: config } = require("../../../../app/package.json");
const CHECK_UPGRADE_INTERVAL = 10 * 60 * 1000;
export function doOpenModal(modal, modalProps = {}) { export function doOpenModal(modal, modalProps = {}) {
return { return {
@ -63,33 +68,31 @@ export function doDownloadUpgrade() {
const state = getState(); const state = getState();
// Make a new directory within temp directory so the filename is guaranteed to be available // Make a new directory within temp directory so the filename is guaranteed to be available
const dir = fs.mkdtempSync( const dir = fs.mkdtempSync(
remote.app.getPath("temp") + require("path").sep remote.app.getPath("temp") + require("path").sep
), ),
upgradeFilename = selectUpgradeFilename(state); upgradeFilename = selectUpgradeFilename(state);
let options = { let options = {
onProgress: p => dispatch(doUpdateDownloadProgress(Math.round(p * 100))), onProgress: p => dispatch(doUpdateDownloadProgress(Math.round(p * 100))),
directory: dir, directory: dir,
}; };
download( download(remote.getCurrentWindow(), selectUpdateUrl(state), options).then(
remote.getCurrentWindow(), downloadItem => {
selectUpdateUrl(state), /**
options
).then(downloadItem => {
/**
* TODO: get the download path directly from the download object. It should just be * TODO: get the download path directly from the download object. It should just be
* downloadItem.getSavePath(), but the copy on the main process is being garbage collected * downloadItem.getSavePath(), but the copy on the main process is being garbage collected
* too soon. * too soon.
*/ */
dispatch({ dispatch({
type: types.UPGRADE_DOWNLOAD_COMPLETED, type: types.UPGRADE_DOWNLOAD_COMPLETED,
data: { data: {
downloadItem, downloadItem,
path: path.join(dir, upgradeFilename), path: path.join(dir, upgradeFilename),
}, },
}); });
}); }
);
dispatch({ dispatch({
type: types.UPGRADE_DOWNLOAD_STARTED, type: types.UPGRADE_DOWNLOAD_STARTED,
@ -129,15 +132,25 @@ export function doCancelUpgrade() {
export function doCheckUpgradeAvailable() { export function doCheckUpgradeAvailable() {
return function(dispatch, getState) { return function(dispatch, getState) {
const state = getState(); const state = getState();
dispatch({
type: types.CHECK_UPGRADE_START,
});
lbry.getAppVersionInfo().then(({ remoteVersion, upgradeAvailable }) => { const success = ({ remoteVersion, upgradeAvailable }) => {
if (upgradeAvailable) { dispatch({
dispatch({ type: types.CHECK_UPGRADE_SUCCESS,
type: types.UPDATE_VERSION, data: {
data: { upgradeAvailable,
version: remoteVersion, remoteVersion,
}, },
}); });
if (
upgradeAvailable &&
!selectCurrentModal(state) &&
(!selectIsUpgradeSkipped(state) ||
remoteVersion !== selectRemoteVersion(state))
) {
dispatch({ dispatch({
type: types.OPEN_MODAL, type: types.OPEN_MODAL,
data: { data: {
@ -145,6 +158,30 @@ export function doCheckUpgradeAvailable() {
}, },
}); });
} }
};
const fail = () => {
dispatch({
type: types.CHECK_UPGRADE_FAIL,
});
};
lbry.getAppVersionInfo().then(success, fail);
};
}
/*
Initiate a timer that will check for an app upgrade every 10 minutes.
*/
export function doCheckUpgradeSubscribe() {
return function(dispatch) {
const checkUpgradeTimer = setInterval(
() => dispatch(doCheckUpgradeAvailable()),
CHECK_UPGRADE_INTERVAL
);
dispatch({
type: types.CHECK_UPGRADE_SUBSCRIBE,
data: { checkUpgradeTimer },
}); });
}; };
} }
@ -153,9 +190,10 @@ export function doCheckDaemonVersion() {
return function(dispatch, getState) { return function(dispatch, getState) {
lbry.version().then(({ lbrynet_version }) => { lbry.version().then(({ lbrynet_version }) => {
dispatch({ dispatch({
type: config.lbrynetDaemonVersion == lbrynet_version type:
? types.DAEMON_VERSION_MATCH config.lbrynetDaemonVersion == lbrynet_version
: types.DAEMON_VERSION_MISMATCH, ? types.DAEMON_VERSION_MATCH
: types.DAEMON_VERSION_MISMATCH,
}); });
}); });
}; };
@ -176,11 +214,18 @@ export function doAlertError(errorList) {
export function doDaemonReady() { export function doDaemonReady() {
return function(dispatch, getState) { return function(dispatch, getState) {
const state = getState();
dispatch(doAuthenticate()); dispatch(doAuthenticate());
dispatch({ type: types.DAEMON_READY }); dispatch({ type: types.DAEMON_READY });
dispatch(doFetchDaemonSettings()); dispatch(doFetchDaemonSettings());
dispatch(doBalanceSubscribe()); dispatch(doBalanceSubscribe());
dispatch(doFetchFileInfosAndPublishedClaims()); dispatch(doFetchFileInfosAndPublishedClaims());
dispatch(doFetchRewardedContent());
if (!selectIsUpgradeSkipped(state)) {
dispatch(doCheckUpgradeAvailable());
}
dispatch(doCheckUpgradeSubscribe());
}; };
} }

View file

@ -51,10 +51,10 @@ export function doResolveUris(uris) {
certificate: null, certificate: null,
}; };
const { claim, certificate, claims_in_channel } = uriResolveInfo && const { claim, certificate, claims_in_channel } =
!uriResolveInfo.error uriResolveInfo && !uriResolveInfo.error
? uriResolveInfo ? uriResolveInfo
: fallbackResolveInfo; : fallbackResolveInfo;
resolveInfo[uri] = { claim, certificate, claims_in_channel }; resolveInfo[uri] = { claim, certificate, claims_in_channel };
} }

View file

@ -45,9 +45,10 @@ export function doFetchCostInfoForUri(uri) {
}, reject); }, reject);
*/ */
const fee = claim.value && claim.value.stream && claim.value.stream.metadata const fee =
? claim.value.stream.metadata.fee claim.value && claim.value.stream && claim.value.stream.metadata
: undefined; ? claim.value.stream.metadata.fee
: undefined;
if (fee === undefined) { if (fee === undefined) {
resolve({ cost: 0, includesData: true }); resolve({ cost: 0, includesData: true });

View file

@ -93,12 +93,11 @@ export function doClaimEligiblePurchaseRewards() {
if (rewardsByType[rewards.TYPE_FIRST_STREAM]) { if (rewardsByType[rewards.TYPE_FIRST_STREAM]) {
dispatch(doClaimRewardType(rewards.TYPE_FIRST_STREAM)); dispatch(doClaimRewardType(rewards.TYPE_FIRST_STREAM));
} else { } else {
[ [rewards.TYPE_MANY_DOWNLOADS, rewards.TYPE_FEATURED_DOWNLOAD].forEach(
rewards.TYPE_MANY_DOWNLOADS, type => {
rewards.TYPE_FEATURED_DOWNLOAD, dispatch(doClaimRewardType(type));
].forEach(type => { }
dispatch(doClaimRewardType(type)); );
});
} }
}; };
} }

View file

@ -64,7 +64,7 @@ reducers[types.SKIP_UPGRADE] = function(state, action) {
sessionStorage.setItem("upgradeSkipped", true); sessionStorage.setItem("upgradeSkipped", true);
return Object.assign({}, state, { return Object.assign({}, state, {
upgradeSkipped: true, isUpgradeSkipped: true,
modal: null, modal: null,
}); });
}; };
@ -75,6 +75,19 @@ reducers[types.UPDATE_VERSION] = function(state, action) {
}); });
}; };
reducers[types.CHECK_UPGRADE_SUCCESS] = function(state, action) {
return Object.assign({}, state, {
isUpgradeAvailable: action.data.upgradeAvailable,
remoteVersion: action.data.remoteVersion,
});
};
reducers[types.CHECK_UPGRADE_SUBSCRIBE] = function(state, action) {
return Object.assign({}, state, {
checkUpgradeTimer: action.data.checkUpgradeTimer,
});
};
reducers[types.OPEN_MODAL] = function(state, action) { reducers[types.OPEN_MODAL] = function(state, action) {
return Object.assign({}, state, { return Object.assign({}, state, {
modal: action.data.modal, modal: action.data.modal,

View file

@ -20,13 +20,19 @@ export const selectUpdateUrl = createSelector(selectPlatform, platform => {
} }
}); });
export const selectVersion = createSelector(_selectState, state => { export const selectRemoteVersion = createSelector(
return state.version; _selectState,
}); state => state.remoteVersion
);
export const selectIsUpgradeAvailable = createSelector(
_selectState,
state => state.isUpgradeAvailable
);
export const selectUpgradeFilename = createSelector( export const selectUpgradeFilename = createSelector(
selectPlatform, selectPlatform,
selectVersion, selectRemoteVersion,
(platform, version) => { (platform, version) => {
switch (platform) { switch (platform) {
case "darwin": case "darwin":
@ -56,9 +62,9 @@ export const selectDownloadComplete = createSelector(
state => state.upgradeDownloadCompleted state => state.upgradeDownloadCompleted
); );
export const selectUpgradeSkipped = createSelector( export const selectIsUpgradeSkipped = createSelector(
_selectState, _selectState,
state => state.upgradeSkipped state => state.isUpgradeSkipped
); );
export const selectUpgradeDownloadPath = createSelector( export const selectUpgradeDownloadPath = createSelector(