From fb3d366fe058847d213f9e889a868877fcbf6159 Mon Sep 17 00:00:00 2001 From: 6ea86b96 <6ea86b96@gmail.com> Date: Sat, 6 May 2017 00:05:33 +0700 Subject: [PATCH] Fix upgrading and start on history --- ui/js/actions/app.js | 18 ++++++++++++++---- ui/js/component/header/index.js | 1 + ui/js/component/header/view.jsx | 2 +- ui/js/reducers/app.js | 1 - 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/ui/js/actions/app.js b/ui/js/actions/app.js index 1f384cbd5..b943f5e4b 100644 --- a/ui/js/actions/app.js +++ b/ui/js/actions/app.js @@ -6,6 +6,7 @@ import { selectUpgradeDownloadItem, selectUpgradeFilename, selectPageTitle, + selectCurrentPath, } from 'selectors/app' const {remote, ipcRenderer, shell} = require('electron'); @@ -16,6 +17,11 @@ const fs = remote.require('fs'); export function doNavigate(path) { return function(dispatch, getState) { + const state = getState() + const previousPath = selectCurrentPath(state) + const previousTitle = selectPageTitle(state) + history.pushState(state, previousTitle, previousPath); + dispatch({ type: types.NAVIGATE, data: { @@ -23,8 +29,8 @@ export function doNavigate(path) { } }) - const state = getState() const pageTitle = selectPageTitle(state) + window.document.title = pageTitle } } @@ -48,8 +54,12 @@ export function doCloseModal() { } export function doHistoryBack() { - return { - type: types.HISTORY_BACK + return function(dispatch, getState) { + if (window.history.length > 1) { + window.history.back(); + } else { + dispatch(doNavigate('discover')) + } } } @@ -152,7 +162,7 @@ export function doCheckUpgradeAvailable() { dispatch({ type: types.UPDATE_VERSION, data: { - version: versionInfo.lbrynet_version + version: remoteVersion, } }) dispatch({ diff --git a/ui/js/component/header/index.js b/ui/js/component/header/index.js index 2a10b5e81..dafdabf32 100644 --- a/ui/js/component/header/index.js +++ b/ui/js/component/header/index.js @@ -1,4 +1,5 @@ import React from 'react' +import lbry from 'lbry' import { connect } from 'react-redux' diff --git a/ui/js/component/header/view.jsx b/ui/js/component/header/view.jsx index 0707b7e10..e5ed26063 100644 --- a/ui/js/component/header/view.jsx +++ b/ui/js/component/header/view.jsx @@ -8,7 +8,7 @@ export const Header = (props) => { back, navigate } = props - + return