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 <maryhipp@Marys-MacBook-Air.local>
This commit is contained in:
Mary Hipp Rogers 2024-01-08 12:15:46 -05:00 committed by GitHub
parent 5d87578746
commit d86d7e5c33
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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'