Skip to content
This repository has been archived by the owner on Jan 2, 2025. It is now read-only.

Commit

Permalink
Redirect pub when group does not have version
Browse files Browse the repository at this point in the history
  • Loading branch information
ericvicenti committed Oct 16, 2023
1 parent 1194d76 commit b51af83
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions frontend/packages/app/components/titlebar/common.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,10 @@ export function useFullReferenceUrl(
const entityTimeline = useEntityTimeline(routeGroupId || pubRouteDocId)
const invertedGroupContent = useInvertedGroupContent(contextGroupId)

let redirectedContext: undefined | PublicationRouteContext = undefined

const navigateReplace = useNavigate('replace')

if (groupRoute) {
const groupExactVersion = groupRoute?.version
return getReferenceUrlOfRoute(
Expand Down Expand Up @@ -221,8 +225,16 @@ export function useFullReferenceUrl(
// this is the main purpose for all this code!
// if the version is not hosted on this site, we should link to hyper.media by setting hostname to undefined
hostname = undefined
// also we want to clear the publication context from the route:
redirectedContext = null
}
}
if (redirectedContext !== undefined) {
navigateReplace({
...pubRoute,
pubContext: redirectedContext,
})
}
return {
url: createPublicWebHmUrl('d', docId.eid, {
version: pub.data?.version,
Expand Down

0 comments on commit b51af83

Please sign in to comment.