Skip to content

Commit

Permalink
make early return more clear
Browse files Browse the repository at this point in the history
  • Loading branch information
MikaelSiidorow committed Feb 1, 2024
1 parent e0836f9 commit 0aefa46
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions apps/cms/src/hooks/revalidate-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,8 @@ export function revalidatePage<T extends TypeWithID>(
getFetchData: (doc: T, req: PayloadRequest) => Promise<unknown>,
): AfterChangeHook<T> {
return ({ doc, req, operation }): T => {
if (
operation !== "update" ||
!("_status" in doc) ||
doc._status !== "published"
) {
const isPublished = "_status" in doc && doc._status === "published";
if (operation !== "update" || !isPublished) {
return doc;
}

Expand Down

0 comments on commit 0aefa46

Please sign in to comment.