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) {
|
export function doHistoryPush(params, title, relativeUrl) {
|
||||||
return function(dispatch, getState) {
|
return function(dispatch, getState) {
|
||||||
let pathParts = window.location.pathname.split("/");
|
|
||||||
pathParts[pathParts.length - 1] = relativeUrl.replace(/^\//, "");
|
|
||||||
const url = pathParts.join("/");
|
|
||||||
title += " - LBRY";
|
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) => {
|
window.addEventListener("popstate", (event, param) => {
|
||||||
const params = event.state;
|
event.preventDefault();
|
||||||
const pathParts = document.location.pathname.split("/");
|
|
||||||
const route = "/" + pathParts[pathParts.length - 1];
|
|
||||||
const queryString = toQueryString(params);
|
|
||||||
|
|
||||||
|
const hash = document.location.hash;
|
||||||
let action;
|
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) => {
|
ipcRenderer.on("open-uri-requested", (event, uri) => {
|
||||||
|
|
|
@ -1,10 +1,16 @@
|
||||||
import * as types from "constants/action_types";
|
import * as types from "constants/action_types";
|
||||||
import lbry from "lbry";
|
import lbry from "lbry";
|
||||||
|
|
||||||
|
const currentPath = () => {
|
||||||
|
const hash = document.location.hash;
|
||||||
|
if (hash !== "") return hash.split("#")[1];
|
||||||
|
else return "/discover";
|
||||||
|
};
|
||||||
|
|
||||||
const reducers = {};
|
const reducers = {};
|
||||||
const defaultState = {
|
const defaultState = {
|
||||||
isLoaded: false,
|
isLoaded: false,
|
||||||
currentPath: "discover",
|
currentPath: currentPath(),
|
||||||
platform: process.platform,
|
platform: process.platform,
|
||||||
upgradeSkipped: sessionStorage.getItem("upgradeSkipped"),
|
upgradeSkipped: sessionStorage.getItem("upgradeSkipped"),
|
||||||
daemonReady: false,
|
daemonReady: false,
|
||||||
|
|
Loading…
Reference in a new issue