mirror of
https://github.com/wu736139669/hapi.git
synced 2026-08-07 06:52:28 +00:00
fix(web): fix navigation in session creation flow with back buttons
- Add back buttons to MachinesPage and SpawnPage for non-Telegram environments - Fix navigation after session creation to clear spawn flow from history - Update useAppGoBack hook to use explicit path navigation for consistent behavior
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import { useCallback } from 'react'
|
||||
import { useLocation, useNavigate, useRouter } from '@tanstack/react-router'
|
||||
import { isTelegramApp } from '@/hooks/useTelegram'
|
||||
|
||||
export function useAppGoBack(): () => void {
|
||||
const navigate = useNavigate()
|
||||
@@ -8,11 +7,7 @@ export function useAppGoBack(): () => void {
|
||||
const pathname = useLocation({ select: (location) => location.pathname })
|
||||
|
||||
return useCallback(() => {
|
||||
if (!isTelegramApp()) {
|
||||
router.history.back()
|
||||
return
|
||||
}
|
||||
|
||||
// Use explicit path navigation for consistent behavior across all environments
|
||||
if (pathname.startsWith('/sessions/')) {
|
||||
navigate({ to: '/sessions' })
|
||||
return
|
||||
@@ -25,6 +20,10 @@ export function useAppGoBack(): () => void {
|
||||
|
||||
if (pathname.startsWith('/machines')) {
|
||||
navigate({ to: '/sessions' })
|
||||
return
|
||||
}
|
||||
|
||||
// Fallback to history.back() for other cases
|
||||
router.history.back()
|
||||
}, [navigate, pathname, router])
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user