From d86d7e5c33fcff5c813cb6c3e2bb4615c80316cc Mon Sep 17 00:00:00 2001 From: Mary Hipp Rogers Date: Mon, 8 Jan 2024 12:15:46 -0500 Subject: [PATCH] do not show toast if 403 is triggered by forbidden image (#5447) * do not show toast if 403 is triggered by lack of image access * remove log * lint --------- Co-authored-by: Mary Hipp --- .../web/src/services/api/authToastMiddleware.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/invokeai/frontend/web/src/services/api/authToastMiddleware.ts b/invokeai/frontend/web/src/services/api/authToastMiddleware.ts index a9cf775383..366f4d06c4 100644 --- a/invokeai/frontend/web/src/services/api/authToastMiddleware.ts +++ b/invokeai/frontend/web/src/services/api/authToastMiddleware.ts @@ -11,6 +11,15 @@ const zRejectedForbiddenAction = z.object({ detail: z.string(), }), }), + meta: z + .object({ + arg: z + .object({ + endpointName: z.string().optional(), + }) + .optional(), + }) + .optional(), }); export const authToastMiddleware: Middleware = @@ -18,6 +27,11 @@ export const authToastMiddleware: Middleware = if (isRejectedWithValue(action)) { try { const parsed = zRejectedForbiddenAction.parse(action); + if (parsed.meta?.arg?.endpointName === 'getImageDTO') { + // do not show toast if problem is image access + return; + } + const { dispatch } = api; const customMessage = parsed.payload.data.detail !== 'Forbidden'