Skip to content

Commit

Permalink
fix(structure): fix issue when reading versins when they don't exist …
Browse files Browse the repository at this point in the history
…/ drafts and published exist
  • Loading branch information
RitaDias committed Feb 25, 2025
1 parent 6aaa6ce commit 88caf35
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ export const DocumentPaneProvider = memo((props: DocumentPaneProviderProps) => {

const initialValue = useUnique(initialValueRaw)
const isInitialValueLoading = initialValue.loading
const onlyHasVersions =
documentVersions && documentVersions.length === 1 && isVersionId(documentVersions[0])

const {patch} = useDocumentOperation(documentId, documentType, selectedReleaseId)
const schemaType = schema.get(documentType) as ObjectSchemaType | undefined
Expand All @@ -179,7 +181,7 @@ export const DocumentPaneProvider = memo((props: DocumentPaneProviderProps) => {
'default',
// check if the selected version is the only version, if it isn't and it doesn't exist in hte release
// then it needs to use the doucmentverisons
getVersionFromId(documentVersions[0]) === selectedReleaseId
!documentVersions || !onlyHasVersions
? selectedReleaseId
: getVersionFromId(documentVersions[0]),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@ export const DocumentPerspectiveList = memo(function DocumentPerspectiveList() {
const {editState, displayed, documentType, documentId} = useDocumentPane()
const {data: documentVersions} = useDocumentVersions({documentId})
const isCreatingDocument = displayed && !displayed._createdAt
const onlyHasVersions = !editState?.published && !editState?.draft && documentVersions?.length
const onlyHasVersions =
(!editState?.published && !editState?.draft && documentVersions?.length > 0) ||
isCreatingDocument

const filteredReleases: FilterReleases = useMemo(() => {
if (!documentVersions) return {notCurrentReleases: [], currentReleases: [], inCreation: null}
Expand Down

0 comments on commit 88caf35

Please sign in to comment.