From 0419e7dc5226080d36dae9971424b0012519a464 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Thu, 28 Dec 2023 19:59:15 -0500 Subject: [PATCH] fix: usePolicy attempting to fetch policies for unsaved entity --- app/hooks/usePolicy.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/hooks/usePolicy.ts b/app/hooks/usePolicy.ts index fe1cfecae..dd8e565c9 100644 --- a/app/hooks/usePolicy.ts +++ b/app/hooks/usePolicy.ts @@ -18,7 +18,12 @@ export default function usePolicy(entity?: string | Model | null) { : ""; React.useEffect(() => { - if (entity && typeof entity !== "string") { + if ( + entity && + typeof entity !== "string" && + !entity.isNew && + !entity.isSaving + ) { // The policy for this model is missing, reload relationships for this model. if (!policies.get(entity.id)) { void entity.loadRelations();