Working on history fix
This commit is contained in:
parent
22fbf13715
commit
5df497182e
3 changed files with 14 additions and 10 deletions
|
@ -33,7 +33,10 @@ export function doNavigate(path, params = {}, options = {}) {
|
||||||
|
|
||||||
const state = getState();
|
const state = getState();
|
||||||
const pageTitle = selectPageTitle(state);
|
const pageTitle = selectPageTitle(state);
|
||||||
dispatch(doHistoryPush({ params, is_last_page: true }, pageTitle, url));
|
const historyState = history.state;
|
||||||
|
dispatch(
|
||||||
|
doHistoryPush({ params, page: historyState.page + 1 }, pageTitle, url)
|
||||||
|
);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,10 +91,10 @@ export function doHistoryBack() {
|
||||||
|
|
||||||
export function doHistoryForward() {
|
export function doHistoryForward() {
|
||||||
return function(dispatch, getState) {
|
return function(dispatch, getState) {
|
||||||
if (!selectIsForwardDisabled(getState())) {
|
// if (!selectIsForwardDisabled(getState())) {
|
||||||
history.forward();
|
history.forward();
|
||||||
dispatch({ type: types.HISTORY_NAVIGATE });
|
dispatch({ type: types.HISTORY_NAVIGATE });
|
||||||
}
|
// }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -279,7 +282,7 @@ export function doDaemonReady() {
|
||||||
const path = window.location.hash || "#/discover";
|
const path = window.location.hash || "#/discover";
|
||||||
const params = parseQueryParams(path.split("?")[1] || "");
|
const params = parseQueryParams(path.split("?")[1] || "");
|
||||||
history.replaceState(
|
history.replaceState(
|
||||||
{ params, is_first_page: true },
|
{ params, is_first_page: true, page: 1 },
|
||||||
document.title,
|
document.title,
|
||||||
`${path}`
|
`${path}`
|
||||||
);
|
);
|
||||||
|
|
|
@ -12,7 +12,6 @@ export const Header = props => {
|
||||||
navigate,
|
navigate,
|
||||||
publish,
|
publish,
|
||||||
} = props;
|
} = props;
|
||||||
console.log(props);
|
|
||||||
return (
|
return (
|
||||||
<header id="header">
|
<header id="header">
|
||||||
<div className="header__item">
|
<div className="header__item">
|
||||||
|
|
|
@ -48,7 +48,6 @@ reducers[types.DAEMON_VERSION_MISMATCH] = function(state, action) {
|
||||||
reducers[types.CHANGE_PATH] = function(state, action) {
|
reducers[types.CHANGE_PATH] = function(state, action) {
|
||||||
return Object.assign({}, state, {
|
return Object.assign({}, state, {
|
||||||
currentPath: action.data.path,
|
currentPath: action.data.path,
|
||||||
isForwardDisabled: !action.data.isBack,
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -166,9 +165,12 @@ reducers[types.WINDOW_FOCUSED] = function(state, action) {
|
||||||
};
|
};
|
||||||
|
|
||||||
reducers[types.HISTORY_NAVIGATE] = (state, action) => {
|
reducers[types.HISTORY_NAVIGATE] = (state, action) => {
|
||||||
|
console.log(history.state);
|
||||||
|
console.log(history.length);
|
||||||
|
console.log(history.state.page === history.length);
|
||||||
return Object.assign({}, state, {
|
return Object.assign({}, state, {
|
||||||
isBackDisabled: !history.state || history.state.is_first_page === true,
|
isBackDisabled: history.state.page === 1,
|
||||||
isForwardDisabled: !history.state,
|
isForwardDisabled: history.state.page > history.length,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue