chore: mirror changes from PR #3276 (#3284)

This commit is contained in:
Jarrod Flesch
2023-09-07 11:06:57 -04:00
committed by GitHub
parent 1092ae6f98
commit abd983f421
4 changed files with 18 additions and 6 deletions

View File

@@ -2,8 +2,6 @@
import type { CollectionConfig } from '../../../../packages/payload/src/collections/config/types'
import type { PayloadRequest } from '../../../../packages/payload/src/types'
import payload from '../../../../packages/payload/src'
export const contextHooksSlug = 'context-hooks'
const ContextHooks: CollectionConfig = {
slug: contextHooksSlug,
@@ -47,12 +45,12 @@ const ContextHooks: CollectionConfig = {
},
],
afterChange: [
async ({ context, doc }) => {
async ({ context, doc, req }) => {
if (context.triggerAfterChange === false) {
// Make sure we don't trigger afterChange again and again in an infinite loop
return
}
await payload.update({
await req.payload.update({
collection: contextHooksSlug,
id: doc.id,
data: {