Merge pull request #28630 from overleaf/dp-detached-pdf-errors

Add fileTreeData checks to FileTreePathProvider

GitOrigin-RevId: 8c4701d9dc02ac30346d82f813f821c8561f98ed
This commit is contained in:
David
2025-09-22 13:11:28 +01:00
committed by Copybot
parent 9d03b59798
commit 693af6da8a

View File

@@ -29,22 +29,34 @@ export const FileTreePathProvider: FC<React.PropsWithChildren> = ({
const projectId = getMeta('ol-project_id')
const pathInFileTree = useCallback(
(id: string) => pathInFolder(fileTreeData, id),
(id: string) => {
if (!fileTreeData) return null
return pathInFolder(fileTreeData, id)
},
[fileTreeData]
)
const findEntityByPathInFileTree = useCallback(
(path: string) => findEntityByPath(fileTreeData, path),
(path: string) => {
if (!fileTreeData) return null
return findEntityByPath(fileTreeData, path)
},
[fileTreeData]
)
const previewByPathInFileTree = useCallback(
(path: string) => previewByPath(fileTreeData, projectId, path),
(path: string) => {
if (!fileTreeData) return null
return previewByPath(fileTreeData, projectId, path)
},
[fileTreeData, projectId]
)
const dirnameInFileTree = useCallback(
(id: string) => dirname(fileTreeData, id),
(id: string) => {
if (!fileTreeData) return null
return dirname(fileTreeData, id)
},
[fileTreeData]
)