Skip to content

Commit

Permalink
chore: debug current path
Browse files Browse the repository at this point in the history
  • Loading branch information
EnixCoda committed May 18, 2023
1 parent 13a118f commit b8abf40
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/components/FileExplorer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { SearchBar } from 'components/SearchBar'
import { useConfigs } from 'containers/ConfigsContext'
import { PortalContext } from 'containers/PortalContext'
import { RepoContext } from 'containers/RepoContext'
import { platform } from 'platforms'
import { useInspector } from 'containers/StateInspector'
import * as React from 'react'
import { usePrevious, useUpdateEffect } from 'react-use'
import { cx } from 'utils/cx'
Expand Down Expand Up @@ -171,13 +171,21 @@ function LoadedFileExplorer({
const renderLabelText = useRenderLabelText(searchKey)

const goToCurrentItem = React.useCallback(() => {
const targetPath = platform.getCurrentPath(metaData.branchName)
const targetPath = getCurrentPath()
if (targetPath) expandTo(targetPath)
}, [metaData.branchName, expandTo])
}, [getCurrentPath, expandTo])

useOnLocationChange(goToCurrentItem)
useAfterRedirect(goToCurrentItem)

const [currentPath, setCurrentPath] = React.useState(() => getCurrentPath())
useAfterRedirect(
React.useCallback(() => {
setCurrentPath(getCurrentPath())
}, [getCurrentPath]),
)
useInspector('CurrentPath', currentPath)

const ref = React.useRef<HTMLDivElement | null>(null)
useFocusOnPendingTarget(
'files',
Expand Down

0 comments on commit b8abf40

Please sign in to comment.