Skip to content

Commit

Permalink
fix: Correct index offset due to directory being taken into account
Browse files Browse the repository at this point in the history
  • Loading branch information
cballevre committed Nov 5, 2024
1 parent a7946e5 commit a058b7c
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/modules/views/Public/PublicFileViewer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit a058b7c

Please sign in to comment.