Fix workspace route state syncing
This commit is contained in:
@@ -20,7 +20,7 @@ import {
|
||||
type ReactElement,
|
||||
type MutableRefObject,
|
||||
} from 'react'
|
||||
import { router, usePathname } from 'expo-router'
|
||||
import { router, useGlobalSearchParams, usePathname } from 'expo-router'
|
||||
import { navigateToWorkspace } from '@/hooks/use-workspace-navigation'
|
||||
import { StyleSheet, UnistylesRuntime, useUnistyles } from 'react-native-unistyles'
|
||||
import { type GestureType } from 'react-native-gesture-handler'
|
||||
@@ -35,8 +35,10 @@ import { projectIconQueryKey } from '@/hooks/use-project-icon-query'
|
||||
import {
|
||||
buildHostNewAgentRoute,
|
||||
buildHostWorkspaceRoute,
|
||||
decodeWorkspaceIdFromPathSegment,
|
||||
parseHostWorkspaceRouteFromPathname,
|
||||
} from '@/utils/host-routes'
|
||||
import { normalizeWorkspaceIdentity } from '@/utils/workspace-identity'
|
||||
import {
|
||||
type SidebarProjectEntry,
|
||||
type SidebarWorkspaceEntry,
|
||||
@@ -1210,6 +1212,10 @@ export function SidebarWorkspaceList({
|
||||
const isMobile = UnistylesRuntime.breakpoint === 'xs' || UnistylesRuntime.breakpoint === 'sm'
|
||||
const isNative = Platform.OS !== 'web'
|
||||
const pathname = usePathname()
|
||||
const routeParams = useGlobalSearchParams<{
|
||||
serverId?: string | string[]
|
||||
workspaceId?: string | string[]
|
||||
}>()
|
||||
const isTauri = getIsTauri()
|
||||
const altDown = useKeyboardShortcutsStore((state) => state.altDown)
|
||||
const cmdOrCtrlDown = useKeyboardShortcutsStore((state) => state.cmdOrCtrlDown)
|
||||
@@ -1224,15 +1230,36 @@ export function SidebarWorkspaceList({
|
||||
if (!pathname) {
|
||||
return null
|
||||
}
|
||||
const parsed = parseHostWorkspaceRouteFromPathname(pathname)
|
||||
if (!parsed) {
|
||||
if (!parseHostWorkspaceRouteFromPathname(pathname)) {
|
||||
return null
|
||||
}
|
||||
return {
|
||||
serverId: parsed.serverId,
|
||||
workspaceId: parsed.workspaceId,
|
||||
|
||||
const serverValue = Array.isArray(routeParams.serverId)
|
||||
? routeParams.serverId[0]
|
||||
: routeParams.serverId
|
||||
const workspaceValue = Array.isArray(routeParams.workspaceId)
|
||||
? routeParams.workspaceId[0]
|
||||
: routeParams.workspaceId
|
||||
const serverId = serverValue?.trim() ?? ''
|
||||
const workspaceId = normalizeWorkspaceIdentity(
|
||||
workspaceValue ? decodeWorkspaceIdFromPathSegment(workspaceValue) : null
|
||||
)
|
||||
if (!serverId || !workspaceId) {
|
||||
const parsed = parseHostWorkspaceRouteFromPathname(pathname)
|
||||
if (!parsed) {
|
||||
return null
|
||||
}
|
||||
return {
|
||||
serverId: parsed.serverId,
|
||||
workspaceId: parsed.workspaceId,
|
||||
}
|
||||
}
|
||||
}, [pathname])
|
||||
|
||||
return {
|
||||
serverId,
|
||||
workspaceId,
|
||||
}
|
||||
}, [pathname, routeParams.serverId, routeParams.workspaceId])
|
||||
|
||||
const projectIconRequests = useMemo(() => {
|
||||
if (!serverId) {
|
||||
|
||||
Reference in New Issue
Block a user