Fix refreshing #273
3 changed files with 19 additions and 15 deletions
|
@ -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}`);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -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) => {
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue