diff --git a/ui/js/actions/app.js b/ui/js/actions/app.js index 9f6214d39..669ce0010 100644 --- a/ui/js/actions/app.js +++ b/ui/js/actions/app.js @@ -67,11 +67,8 @@ export function doHistoryBack() { export function doHistoryPush(params, title, relativeUrl) { return function(dispatch, getState) { - let pathParts = window.location.pathname.split("/"); - pathParts[pathParts.length - 1] = relativeUrl.replace(/^\//, ""); - const url = pathParts.join("/"); title += " - LBRY"; - history.pushState(params, title, url); + history.pushState(params, title, `#${relativeUrl}`); }; } diff --git a/ui/js/main.js b/ui/js/main.js index 78eceb235..331eccc11 100644 --- a/ui/js/main.js +++ b/ui/js/main.js @@ -28,19 +28,20 @@ window.addEventListener("contextmenu", event => { }); window.addEventListener("popstate", (event, param) => { - const params = event.state; - const pathParts = document.location.pathname.split("/"); - const route = "/" + pathParts[pathParts.length - 1]; - const queryString = toQueryString(params); + event.preventDefault(); + const hash = document.location.hash; let action; - if (route.match(/html$/)) { - action = doChangePath("/discover"); - } else { - action = doChangePath(`${route}?${queryString}`); - } - app.store.dispatch(action); + if (hash !== "") { + const url = hash.split("#")[1]; + const params = event.state; + const queryString = toQueryString(params); + + app.store.dispatch(doChangePath(`${url}?${queryString}`)); + } else { + app.store.dispatch(doChangePath("/discover")); + } }); ipcRenderer.on("open-uri-requested", (event, uri) => { diff --git a/ui/js/reducers/app.js b/ui/js/reducers/app.js index d5c95bde5..2a638ede4 100644 --- a/ui/js/reducers/app.js +++ b/ui/js/reducers/app.js @@ -1,10 +1,16 @@ import * as types from "constants/action_types"; import lbry from "lbry"; +const currentPath = () => { + const hash = document.location.hash; + if (hash !== "") return hash.split("#")[1]; + else return "/discover"; +}; + const reducers = {}; const defaultState = { isLoaded: false, - currentPath: "discover", + currentPath: currentPath(), platform: process.platform, upgradeSkipped: sessionStorage.getItem("upgradeSkipped"), daemonReady: false,