Skip to content

Commit

Permalink
fix(ui): conditionally fetches versions based on read access
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobsfletch committed Apr 26, 2024
1 parent a943c7e commit 7111834
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/ui/src/providers/DocumentInfo/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ export const DocumentInfoProvider: React.FC<
}

const isEditing = Boolean(id)
const shouldFetchVersions = Boolean(versionsConfig && docPermissions?.readVersions?.permission)

const getVersions = useCallback(async () => {
let versionFetchURL
let publishedFetchURL
const shouldFetchVersions = Boolean(versionsConfig)
let unpublishedVersionJSON = null
let versionJSON = null
let shouldFetch = true
Expand Down Expand Up @@ -209,7 +209,7 @@ export const DocumentInfoProvider: React.FC<
setVersions(versionJSON)
setUnpublishedVersions(unpublishedVersionJSON)
}
}, [i18n, globalSlug, collectionSlug, id, baseURL, locale, versionsConfig])
}, [i18n, globalSlug, collectionSlug, id, baseURL, locale, versionsConfig, shouldFetchVersions])

const getDocPermissions = React.useCallback(async () => {
let docAccessURL: string
Expand Down

0 comments on commit 7111834

Please sign in to comment.