mirror of
https://github.com/fsolla/teqo.git
synced 2026-11-13 15:13:07 +00:00
react-audit(família 5): Media.ts sem hooks de revalidação — getCachedDocumentById('media') (documentReads.ts:43) nunca invalidava em edição/deleção no admin; afterChange+afterDelete espelham Post/Petition
This commit is contained in:
parent
43a3b21cf4
commit
63cef265c2
1 changed files with 16 additions and 0 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import { canManagePublishedContent } from '@/utilities/campaignAccess'
|
||||
import { revalidateDocumentById } from '@/utilities/documents'
|
||||
import type { CollectionConfig } from 'payload'
|
||||
|
||||
export const Media: CollectionConfig = {
|
||||
|
|
@ -18,6 +19,21 @@ export const Media: CollectionConfig = {
|
|||
update: canManagePublishedContent,
|
||||
delete: canManagePublishedContent,
|
||||
},
|
||||
// The public pages read media through `getCachedDocumentById('media', …)`
|
||||
// (`unstable_cache` under the `document_media:<id>` tag), so admin edits and
|
||||
// deletions must bust that cache — same contract as Post/Petition.
|
||||
hooks: {
|
||||
afterChange: [
|
||||
({ doc, previousDoc }) => {
|
||||
revalidateDocumentById('media', previousDoc?.id ?? doc.id)
|
||||
},
|
||||
],
|
||||
afterDelete: [
|
||||
({ doc }) => {
|
||||
revalidateDocumentById('media', doc.id)
|
||||
},
|
||||
],
|
||||
},
|
||||
fields: [
|
||||
{
|
||||
name: 'alt',
|
||||
|
|
|
|||
Loading…
Reference in a new issue