mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-12 02:42:25 -05:00
14 lines
475 B
TypeScript
14 lines
475 B
TypeScript
|
import { useMemo } from 'react'
|
||
|
import useScopeValue from '../../../shared/hooks/use-scope-value'
|
||
|
import { File, FileOrDirectory, filterFolders } from '../utils/file'
|
||
|
|
||
|
export const useCurrentProjectFolders: () => [
|
||
|
File[] | undefined,
|
||
|
File
|
||
|
] = () => {
|
||
|
const [rootFolder] = useScopeValue<FileOrDirectory>('rootFolder')
|
||
|
const rootFile = { ...rootFolder, path: '' }
|
||
|
const folders = useMemo(() => filterFolders(rootFolder), [rootFolder])
|
||
|
return [folders, rootFile]
|
||
|
}
|