pl-fe: do not make admin api requests when unauthenticated lol
Signed-off-by: nicole mikołajczyk <git@mkljczk.pl>
This commit is contained in:
@ -52,7 +52,7 @@ const usePendingUsersCount = () => {
|
|||||||
return useInfiniteQuery({
|
return useInfiniteQuery({
|
||||||
...pendingUsersQuery,
|
...pendingUsersQuery,
|
||||||
select: (data) => data.pages.at(-1)?.total || data.pages.map(page => page.items).flat().length || 0,
|
select: (data) => data.pages.at(-1)?.total || data.pages.map(page => page.items).flat().length || 0,
|
||||||
enabled: account?.is_admin || account?.is_moderator,
|
enabled: !!(account?.is_admin || account?.is_moderator),
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -39,7 +39,7 @@ const usePendingReportsCount = () => {
|
|||||||
return useInfiniteQuery({
|
return useInfiniteQuery({
|
||||||
...pendingReportsQuery,
|
...pendingReportsQuery,
|
||||||
select: (data) => data.pages.at(-1)?.total || data.pages.map(page => page.items).flat().length || 0,
|
select: (data) => data.pages.at(-1)?.total || data.pages.map(page => page.items).flat().length || 0,
|
||||||
enabled: !!instance.fetched && (account?.is_admin || account?.is_moderator),
|
enabled: !!instance.fetched && !!(account?.is_admin || account?.is_moderator),
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -37,7 +37,7 @@ const makePaginatedResponseQuery = <T1 extends Array<any>, T2, T3 = PaginatedRes
|
|||||||
|
|
||||||
return items as T3;
|
return items as T3;
|
||||||
}),
|
}),
|
||||||
enabled: enabled === 'isLoggedIn' ? !!account : enabled === 'isAdmin' ? (account?.is_admin || account?.is_moderator) : (enabled?.(...params) ?? true),
|
enabled: enabled === 'isLoggedIn' ? !!account : enabled === 'isAdmin' ? !!(account?.is_admin || account?.is_moderator) : (enabled?.(...params) ?? true),
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user