Skip to content

Commit

Permalink
moves isInitializing into state
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobsfletch committed Oct 7, 2024
1 parent e2bb53b commit 18a1610
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions packages/ui/src/providers/DocumentInfo/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,10 @@ const DocumentInfo: React.FC<
const [documentIsLocked, setDocumentIsLocked] = useState<boolean | undefined>(false)
const [currentEditor, setCurrentEditor] = useState<ClientUser | null>(null)

const isInitializing = initialState === undefined || data === undefined
const [isInitializing, setIsInitializing] = useState(
initialState === undefined || data === undefined,
)

const [unpublishedVersions, setUnpublishedVersions] =
useState<PaginatedDocs<TypeWithVersion<any>>>(null)

Expand Down Expand Up @@ -213,6 +216,12 @@ const DocumentInfo: React.FC<
[serverURL, api, globalSlug],
)

useEffect(() => {
if (initialState !== undefined && data !== undefined) {
setIsInitializing(false)
}
}, [initialState, data])

useEffect(() => {
if (!isLockingEnabled || (!id && !globalSlug)) {
return
Expand Down Expand Up @@ -552,8 +561,7 @@ const DocumentInfo: React.FC<
prevLocale.current = locale
}

setData(undefined)
setInitialState(undefined)
setIsInitializing(true)
setIsError(false)
setIsLoading(true)

Expand Down

0 comments on commit 18a1610

Please sign in to comment.