mirror of
https://github.com/captbaritone/webamp.git
synced 2026-07-23 18:17:38 +00:00
Don't try to pollute history
This commit is contained in:
parent
ff5ffc677b
commit
219fd10eb2
1 changed files with 5 additions and 2 deletions
|
|
@ -10,7 +10,7 @@ export function createStore() {
|
|||
|
||||
const store = createReduxStore(reducer, applyMiddleware(epicMiddleware));
|
||||
epicMiddleware.run(rootEpic);
|
||||
let lastUrl = null;
|
||||
let lastUrl = window.location.pathname;
|
||||
window.onpopstate = function () {
|
||||
store.dispatch({ type: "URL_CHANGED", location: document.location });
|
||||
};
|
||||
|
|
@ -21,11 +21,14 @@ export function createStore() {
|
|||
const state = store.getState();
|
||||
const url = Selectors.getUrl(state);
|
||||
if (url !== lastUrl) {
|
||||
console.log(
|
||||
`url ${url} does not match ${lastUrl} so we're adding a history entry`
|
||||
);
|
||||
window.ga("set", "page", url);
|
||||
if (lastUrl != null) {
|
||||
window.ga("send", "pageview");
|
||||
}
|
||||
window.history.pushState({}, Selectors.getPageTitle(state), url);
|
||||
window.history.replaceState({}, Selectors.getPageTitle(state), url);
|
||||
lastUrl = url;
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue