Skip to content

Commit

Permalink
Fix: Some urls causing loading loop
Browse files Browse the repository at this point in the history
  • Loading branch information
reglim committed Mar 27, 2023
1 parent a8ce060 commit 7229b5e
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion web/src/pages/Docs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,25 @@ export default function Docs (): JSX.Element {

// replace if the state is the same or the url contained latest
// this makes sure it is possible to go back to the overview page
if (window.location.hash.substring(1) === url || window.location.hash.includes(`${project}/latest`)) {
if (window.location.hash.includes(`${project}/latest`)) {
navigate(url, { replace: true })
return
}

const oldUrl = window.location.hash.substring(1)
const oldProject = oldUrl.split('/')[1]
const oldVersion = oldUrl.split('/')[2]
const oldPage = oldUrl.split('/')[3].split('?')[0]
const oldHideUi = oldUrl.includes('hide-ui=true')

const isSameUrl = oldProject === project && oldVersion === version && oldPage === page && oldHideUi === hideUi

console.log('update url', url, oldUrl, oldProject, oldVersion, oldPage, project, version, page, oldHideUi, hideUi, isSameUrl)

if (isSameUrl) {
return
}

navigate(url)
}, [project, version, page, hideUi])

Expand All @@ -94,6 +108,8 @@ export default function Docs (): JSX.Element {
return
}

console.log('update page', newPage, page)

setPage(newPage)
}, [location])

Expand Down

0 comments on commit 7229b5e

Please sign in to comment.