Skip to content

Commit

Permalink
reverts default edit view onChange
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobsfletch committed Oct 4, 2024
1 parent 2cd9594 commit 2203d60
Showing 1 changed file with 23 additions and 16 deletions.
39 changes: 23 additions & 16 deletions packages/next/src/views/Edit/Default/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
DocumentFields,
Form,
type FormProps,
getFormStateFetch,
OperationProvider,
RenderComponent,
Upload,
Expand All @@ -15,7 +16,7 @@ import {
useDocumentEvents,
useDocumentInfo,
useEditDepth,
useServerFunctions,
// useServerFunctions,
useUploadEdits,
} from '@payloadcms/ui'
import {
Expand Down Expand Up @@ -79,13 +80,14 @@ export const DefaultEditView: React.FC = () => {

const { refreshCookieAsync, user } = useAuth()

const { getFormState } = useServerFunctions()
// const { getFormState } = useServerFunctions()

const {
config,
config: {
admin: { user: userSlug },
routes: { admin: adminRoute },
routes: { admin: adminRoute, api },
serverURL,
},
getEntityConfig,
} = useConfig()
Expand Down Expand Up @@ -243,16 +245,20 @@ export const DefaultEditView: React.FC = () => {

const docPreferences = await getDocPreferences()

const { lockedState, state } = await getFormState({
id,
collectionSlug,
docPreferences,
formState: prevFormState,
globalSlug,
operation,
returnLockStatus: isLockingEnabled ? true : false,
schemaPath,
updateLastEdited,
const { lockedState, state } = await getFormStateFetch({
api,
body: {
id,
collectionSlug,
docPreferences,
formState: prevFormState,
globalSlug,
operation,
returnLockStatus: isLockingEnabled ? true : false,
schemaPath,
updateLastEdited,
},
serverURL,
})

setDocumentIsLocked(true)
Expand All @@ -275,9 +281,9 @@ export const DefaultEditView: React.FC = () => {
documentLockStateRef.current = documentLockStateRef.current = {
hasShownLockedModal: documentLockStateRef.current?.hasShownLockedModal || false,
isLocked: true,
user: lockedState.user as ClientUser,
user: lockedState.user,
}
setCurrentEditor(lockedState.user as ClientUser)
setCurrentEditor(lockedState.user)
}
}
}
Expand All @@ -296,7 +302,8 @@ export const DefaultEditView: React.FC = () => {
isLockingEnabled,
setDocumentIsLocked,
lastUpdateTime,
getFormState,
serverURL,
api,
],
)

Expand Down

0 comments on commit 2203d60

Please sign in to comment.