diff --git a/src/modules/views/Public/PublicFileViewer.jsx b/src/modules/views/Public/PublicFileViewer.jsx index e4dcc4b2a4..ccb22cd430 100644 --- a/src/modules/views/Public/PublicFileViewer.jsx +++ b/src/modules/views/Public/PublicFileViewer.jsx @@ -16,19 +16,17 @@ const PublicFileViewer = () => { const currentFolderId = useCurrentFolderId() const filesResult = usePublicFilesQuery(currentFolderId) - const files = filesResult.data + const viewableFiles = filesResult.data.filter(f => f.type !== 'directory') const currentIndex = useMemo(() => { - return files.findIndex(f => f.id === fileId) - }, [files, fileId]) + return viewableFiles.findIndex(f => f.id === fileId) + }, [viewableFiles, fileId]) const hasCurrentIndex = useMemo(() => currentIndex != -1, [currentIndex]) const viewerIndex = useMemo( () => (hasCurrentIndex ? currentIndex : 0), [hasCurrentIndex, currentIndex] ) - const viewableFiles = files.filter(f => f.type !== 'directory') - const handleChange = ({ _id }) => { navigate(`../${_id}`, { relative: 'path'