Skip to content

Commit

Permalink
Merge pull request #548 from dappforce/fix/back
Browse files Browse the repository at this point in the history
Fix back button issue
  • Loading branch information
olehmell authored Feb 20, 2024
2 parents a7c485a + cc75764 commit 3d1ab0d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/components/BackButton.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { env } from '@/env.mjs'
import useIsInIframe from '@/hooks/useIsInIframe'
import { useLocation } from '@/stores/location'
import { getCurrentUrlOrigin } from '@/utils/links'
import { useRouter } from 'next/router'
import urlJoin from 'url-join'
import Button, { ButtonProps } from './Button'

export type BackButtonProps = ButtonProps & {
Expand All @@ -24,7 +26,10 @@ export default function BackButton({

const hasBackToCurrentSession = !!prevUrl

const prevUrlPathname = prevUrl?.replace(getCurrentUrlOrigin(), '')
const prevUrlPathname = prevUrl?.replace(
urlJoin(getCurrentUrlOrigin(), env.NEXT_PUBLIC_BASE_PATH),
''
)
let isDefaultBackLinkSameAsPrevUrl = defaultBackLink === prevUrlPathname
if (homeLinks.includes(defaultBackLink)) {
isDefaultBackLinkSameAsPrevUrl = homeLinks.includes(prevUrlPathname ?? '')
Expand Down
2 changes: 1 addition & 1 deletion src/utils/links.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function getHubIdFromUrl(currentPath: CurrentPath) {
export function getHubPageLink(currentPath: CurrentPath) {
const hubId = getHubIdFromUrl(currentPath)
const isWidgetRoute = currentPath.pathname?.includes('/widget')
if (!isWidgetRoute) return `/hub/${hubId ?? ''}`
if (!isWidgetRoute) return `/${hubId ?? ''}`
return `/widget/${hubId ?? ''}`
}

Expand Down

0 comments on commit 3d1ab0d

Please sign in to comment.