mirror of
https://github.com/fsolla/teqo.git
synced 2026-11-23 06:33:06 +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
34c04d6966
commit
d2aa70f0c5
1 changed files with 16 additions and 0 deletions
|
|
@ -1,4 +1,5 @@
|
||||||
import { canManagePublishedContent } from '@/utilities/campaignAccess'
|
import { canManagePublishedContent } from '@/utilities/campaignAccess'
|
||||||
|
import { revalidateDocumentById } from '@/utilities/documents'
|
||||||
import type { CollectionConfig } from 'payload'
|
import type { CollectionConfig } from 'payload'
|
||||||
|
|
||||||
export const Media: CollectionConfig = {
|
export const Media: CollectionConfig = {
|
||||||
|
|
@ -18,6 +19,21 @@ export const Media: CollectionConfig = {
|
||||||
update: canManagePublishedContent,
|
update: canManagePublishedContent,
|
||||||
delete: 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: [
|
fields: [
|
||||||
{
|
{
|
||||||
name: 'alt',
|
name: 'alt',
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue