Try improve history navigation by pushing popup changes
This commit is contained in:
		| @@ -23,7 +23,12 @@ const updateQueryParams = (id = null, type = null) => { | |||||||
|     window.location.port ? `:${window.location.port}` : "" |     window.location.port ? `:${window.location.port}` : "" | ||||||
|   }${window.location.pathname}${params.toString().length ? `?${params}` : ""}`; |   }${window.location.pathname}${params.toString().length ? `?${params}` : ""}`; | ||||||
|  |  | ||||||
|  |   if (!window.preventPushState) { | ||||||
|  |     window.history.pushState({}, "search", url); | ||||||
|  |     window.preventPushState = false; | ||||||
|  |   } else { | ||||||
|     window.history.replaceState({}, "search", url); |     window.history.replaceState({}, "search", url); | ||||||
|  |   } | ||||||
| }; | }; | ||||||
|  |  | ||||||
| export default { | export default { | ||||||
|   | |||||||
| @@ -87,9 +87,13 @@ const loggedIn = () => store.getters["user/loggedIn"]; | |||||||
| const popupIsOpen = () => store.getters["popup/isOpen"]; | const popupIsOpen = () => store.getters["popup/isOpen"]; | ||||||
| const hamburgerIsOpen = () => store.getters["hamburger/isOpen"]; | const hamburgerIsOpen = () => store.getters["hamburger/isOpen"]; | ||||||
|  |  | ||||||
|  | window.preventPushState = false; | ||||||
|  | window.onpopstate = () => (window.preventPushState = true); | ||||||
|  |  | ||||||
| router.beforeEach((to, from, next) => { | router.beforeEach((to, from, next) => { | ||||||
|   store.dispatch("documentTitle/updateTitle", to.name); |   store.dispatch("documentTitle/updateTitle", to.name); | ||||||
|   const { movie, show, person } = to.query; |   const { movie, show, person } = to.query; | ||||||
|  |  | ||||||
|   if (movie) store.dispatch("popup/open", { id: movie, type: "movie" }); |   if (movie) store.dispatch("popup/open", { id: movie, type: "movie" }); | ||||||
|   else if (show) store.dispatch("popup/open", { id: show, type: "show" }); |   else if (show) store.dispatch("popup/open", { id: show, type: "show" }); | ||||||
|   else if (person) store.dispatch("popup/open", { id: person, type: "person" }); |   else if (person) store.dispatch("popup/open", { id: person, type: "person" }); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user