Fix refreshing #273

Merged
6ea86b96 merged 1 commit from refreshing into master 2017-06-23 17:26:46 +02:00
3 changed files with 19 additions and 15 deletions

View file

@ -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}`);
};
}

View file

@ -28,19 +28,20 @@ window.addEventListener("contextmenu", event => {
});
window.addEventListener("popstate", (event, param) => {
event.preventDefault();
const hash = document.location.hash;
let action;
if (hash !== "") {
const url = hash.split("#")[1];
const params = event.state;
const pathParts = document.location.pathname.split("/");
const route = "/" + pathParts[pathParts.length - 1];
const queryString = toQueryString(params);
let action;
if (route.match(/html$/)) {
action = doChangePath("/discover");
app.store.dispatch(doChangePath(`${url}?${queryString}`));
} else {
action = doChangePath(`${route}?${queryString}`);
app.store.dispatch(doChangePath("/discover"));
}
app.store.dispatch(action);
});
ipcRenderer.on("open-uri-requested", (event, uri) => {

View file

@ -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,