diff --git a/ui/js/component/app/index.js b/ui/js/component/app/index.js
index b917c04f7..66b50bb71 100644
--- a/ui/js/component/app/index.js
+++ b/ui/js/component/app/index.js
@@ -6,9 +6,8 @@ import {
selectActiveHistoryEntry,
} from "redux/selectors/navigation";
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 { doFetchRewardedContent } from "redux/actions/content";
import App from "./view";
const select = (state, props) => ({
@@ -20,8 +19,6 @@ const select = (state, props) => ({
const perform = dispatch => ({
alertError: errorList => dispatch(doAlertError(errorList)),
- checkUpgradeAvailable: () => dispatch(doCheckUpgradeAvailable()),
- fetchRewardedContent: () => dispatch(doFetchRewardedContent()),
recordScroll: scrollPosition => dispatch(doRecordScroll(scrollPosition)),
});
diff --git a/ui/js/component/app/view.jsx b/ui/js/component/app/view.jsx
index 7a54b0de0..edc9fa2dc 100644
--- a/ui/js/component/app/view.jsx
+++ b/ui/js/component/app/view.jsx
@@ -13,23 +13,11 @@ class App extends React.PureComponent {
}
componentWillMount() {
- const {
- alertError,
- checkUpgradeAvailable,
- fetchRewardedContent,
- } = this.props;
+ const { alertError } = this.props;
document.addEventListener("unhandledError", event => {
alertError(event.detail);
});
-
- if (!this.props.upgradeSkipped) {
- checkUpgradeAvailable();
- }
-
- fetchRewardedContent();
-
- this.setTitleFromProps(this.props);
}
componentDidMount() {
diff --git a/ui/js/component/dateTime/index.js b/ui/js/component/dateTime/index.js
index 106de7126..dbef1e030 100644
--- a/ui/js/component/dateTime/index.js
+++ b/ui/js/component/dateTime/index.js
@@ -5,9 +5,10 @@ import { doFetchBlock } from "redux/actions/wallet";
import DateTime from "./view";
const select = (state, props) => ({
- date: !props.date && props.block
- ? makeSelectBlockDate(props.block)(state)
- : props.date,
+ date:
+ !props.date && props.block
+ ? makeSelectBlockDate(props.block)(state)
+ : props.date,
});
const perform = dispatch => ({
diff --git a/ui/js/component/header/index.js b/ui/js/component/header/index.js
index e461f4efa..4e2a2d078 100644
--- a/ui/js/component/header/index.js
+++ b/ui/js/component/header/index.js
@@ -12,18 +12,21 @@ import {
doHistoryForward,
} from "redux/actions/navigation";
import Header from "./view";
+import { selectIsUpgradeAvailable } from "../../selectors/app";
+import { doDownloadUpgrade } from "../../actions/app";
const select = state => ({
isBackDisabled: selectIsBackDisabled(state),
isForwardDisabled: selectIsForwardDisabled(state),
+ isUpgradeAvailable: selectIsUpgradeAvailable(state),
balance: formatCredits(selectBalance(state) || 0, 1),
- publish: __("Publish"),
});
const perform = dispatch => ({
navigate: path => dispatch(doNavigate(path)),
back: () => dispatch(doHistoryBack()),
forward: () => dispatch(doHistoryForward()),
+ downloadUpgrade: () => dispatch(doDownloadUpgrade()),
});
export default connect(select, perform)(Header);
diff --git a/ui/js/component/header/view.jsx b/ui/js/component/header/view.jsx
index 89f6df923..7bbf9899e 100644
--- a/ui/js/component/header/view.jsx
+++ b/ui/js/component/header/view.jsx
@@ -9,8 +9,9 @@ export const Header = props => {
forward,
isBackDisabled,
isForwardDisabled,
+ isUpgradeAvailable,
navigate,
- publish,
+ downloadUpgrade,
} = props;
return (
- {__("Your file has been published to LBRY at the address")}
- {" "}{this.state.uri}
!
+ {__("Your file has been published to LBRY at the address")}{" "}
+ {this.state.uri}
!
{__(
diff --git a/ui/js/component/uriIndicator/view.jsx b/ui/js/component/uriIndicator/view.jsx
index bff2cbf97..3fa1cb41f 100644
--- a/ui/js/component/uriIndicator/view.jsx
+++ b/ui/js/component/uriIndicator/view.jsx
@@ -60,13 +60,17 @@ class UriIndicator extends React.PureComponent {
const inner = (
- {channelName} {" "}
- {!signatureIsValid
- ?
- LBRY is controlled and powered by a blockchain asset called {" "}
-
- You currently have
- However, there are a variety of ways to get credits, including
- more than {" "}
- {totalRewardValue
- ?
- But you probably knew this, since you've already got{" "}
-
+ You currently have
+ However, there are a variety of ways to get credits, including
+ more than{" "}
+ {totalRewardValue ? (
+
+ But you probably knew this, since you've already got{" "}
+ {__("Blockchain 101")}
{__("Developer?")}
- {__("You can also")}
- {" "}
+ {__("You can also")}{" "}
dispatch(doUpdateDownloadProgress(Math.round(p * 100))),
directory: dir,
};
- download(
- remote.getCurrentWindow(),
- selectUpdateUrl(state),
- options
- ).then(downloadItem => {
- /**
+ download(remote.getCurrentWindow(), selectUpdateUrl(state), options).then(
+ downloadItem => {
+ /**
* 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
* too soon.
*/
- dispatch({
- type: types.UPGRADE_DOWNLOAD_COMPLETED,
- data: {
- downloadItem,
- path: path.join(dir, upgradeFilename),
- },
- });
- });
+ dispatch({
+ type: types.UPGRADE_DOWNLOAD_COMPLETED,
+ data: {
+ downloadItem,
+ path: path.join(dir, upgradeFilename),
+ },
+ });
+ }
+ );
dispatch({
type: types.UPGRADE_DOWNLOAD_STARTED,
@@ -129,15 +132,25 @@ export function doCancelUpgrade() {
export function doCheckUpgradeAvailable() {
return function(dispatch, getState) {
const state = getState();
+ dispatch({
+ type: types.CHECK_UPGRADE_START,
+ });
- lbry.getAppVersionInfo().then(({ remoteVersion, upgradeAvailable }) => {
- if (upgradeAvailable) {
- dispatch({
- type: types.UPDATE_VERSION,
- data: {
- version: remoteVersion,
- },
- });
+ const success = ({ remoteVersion, upgradeAvailable }) => {
+ dispatch({
+ type: types.CHECK_UPGRADE_SUCCESS,
+ data: {
+ upgradeAvailable,
+ remoteVersion,
+ },
+ });
+
+ if (
+ upgradeAvailable &&
+ !selectCurrentModal(state) &&
+ (!selectIsUpgradeSkipped(state) ||
+ remoteVersion !== selectRemoteVersion(state))
+ ) {
dispatch({
type: types.OPEN_MODAL,
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) {
lbry.version().then(({ lbrynet_version }) => {
dispatch({
- type: config.lbrynetDaemonVersion == lbrynet_version
- ? types.DAEMON_VERSION_MATCH
- : types.DAEMON_VERSION_MISMATCH,
+ type:
+ config.lbrynetDaemonVersion == lbrynet_version
+ ? types.DAEMON_VERSION_MATCH
+ : types.DAEMON_VERSION_MISMATCH,
});
});
};
@@ -176,11 +214,18 @@ export function doAlertError(errorList) {
export function doDaemonReady() {
return function(dispatch, getState) {
+ const state = getState();
+
dispatch(doAuthenticate());
dispatch({ type: types.DAEMON_READY });
dispatch(doFetchDaemonSettings());
dispatch(doBalanceSubscribe());
dispatch(doFetchFileInfosAndPublishedClaims());
+ dispatch(doFetchRewardedContent());
+ if (!selectIsUpgradeSkipped(state)) {
+ dispatch(doCheckUpgradeAvailable());
+ }
+ dispatch(doCheckUpgradeSubscribe());
};
}
diff --git a/ui/js/redux/actions/content.js b/ui/js/redux/actions/content.js
index 886fb28d3..ab3b630a8 100644
--- a/ui/js/redux/actions/content.js
+++ b/ui/js/redux/actions/content.js
@@ -51,10 +51,10 @@ export function doResolveUris(uris) {
certificate: null,
};
- const { claim, certificate, claims_in_channel } = uriResolveInfo &&
- !uriResolveInfo.error
- ? uriResolveInfo
- : fallbackResolveInfo;
+ const { claim, certificate, claims_in_channel } =
+ uriResolveInfo && !uriResolveInfo.error
+ ? uriResolveInfo
+ : fallbackResolveInfo;
resolveInfo[uri] = { claim, certificate, claims_in_channel };
}
diff --git a/ui/js/redux/actions/cost_info.js b/ui/js/redux/actions/cost_info.js
index 70a1a5a36..8420e3cd4 100644
--- a/ui/js/redux/actions/cost_info.js
+++ b/ui/js/redux/actions/cost_info.js
@@ -45,9 +45,10 @@ export function doFetchCostInfoForUri(uri) {
}, reject);
*/
- const fee = claim.value && claim.value.stream && claim.value.stream.metadata
- ? claim.value.stream.metadata.fee
- : undefined;
+ const fee =
+ claim.value && claim.value.stream && claim.value.stream.metadata
+ ? claim.value.stream.metadata.fee
+ : undefined;
if (fee === undefined) {
resolve({ cost: 0, includesData: true });
diff --git a/ui/js/redux/actions/rewards.js b/ui/js/redux/actions/rewards.js
index 9ebc3d715..3bdf140e8 100644
--- a/ui/js/redux/actions/rewards.js
+++ b/ui/js/redux/actions/rewards.js
@@ -93,12 +93,11 @@ export function doClaimEligiblePurchaseRewards() {
if (rewardsByType[rewards.TYPE_FIRST_STREAM]) {
dispatch(doClaimRewardType(rewards.TYPE_FIRST_STREAM));
} else {
- [
- rewards.TYPE_MANY_DOWNLOADS,
- rewards.TYPE_FEATURED_DOWNLOAD,
- ].forEach(type => {
- dispatch(doClaimRewardType(type));
- });
+ [rewards.TYPE_MANY_DOWNLOADS, rewards.TYPE_FEATURED_DOWNLOAD].forEach(
+ type => {
+ dispatch(doClaimRewardType(type));
+ }
+ );
}
};
}
diff --git a/ui/js/redux/reducers/app.js b/ui/js/redux/reducers/app.js
index d7bc2cd6b..b44e84ccb 100644
--- a/ui/js/redux/reducers/app.js
+++ b/ui/js/redux/reducers/app.js
@@ -64,7 +64,7 @@ reducers[types.SKIP_UPGRADE] = function(state, action) {
sessionStorage.setItem("upgradeSkipped", true);
return Object.assign({}, state, {
- upgradeSkipped: true,
+ isUpgradeSkipped: true,
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) {
return Object.assign({}, state, {
modal: action.data.modal,
diff --git a/ui/js/redux/selectors/app.js b/ui/js/redux/selectors/app.js
index c721916c0..24c2f2b95 100644
--- a/ui/js/redux/selectors/app.js
+++ b/ui/js/redux/selectors/app.js
@@ -20,13 +20,19 @@ export const selectUpdateUrl = createSelector(selectPlatform, platform => {
}
});
-export const selectVersion = createSelector(_selectState, state => {
- return state.version;
-});
+export const selectRemoteVersion = createSelector(
+ _selectState,
+ state => state.remoteVersion
+);
+
+export const selectIsUpgradeAvailable = createSelector(
+ _selectState,
+ state => state.isUpgradeAvailable
+);
export const selectUpgradeFilename = createSelector(
selectPlatform,
- selectVersion,
+ selectRemoteVersion,
(platform, version) => {
switch (platform) {
case "darwin":
@@ -56,9 +62,9 @@ export const selectDownloadComplete = createSelector(
state => state.upgradeDownloadCompleted
);
-export const selectUpgradeSkipped = createSelector(
+export const selectIsUpgradeSkipped = createSelector(
_selectState,
- state => state.upgradeSkipped
+ state => state.isUpgradeSkipped
);
export const selectUpgradeDownloadPath = createSelector(