فهرست منبع

Added should fetch condition to useSWRxApplicableGrant call

Taichi Masuyama 3 سال پیش
والد
کامیت
2d1ca0a684
1فایلهای تغییر یافته به همراه6 افزوده شده و 2 حذف شده
  1. 6 2
      packages/app/src/components/Page/FixPageGrantAlert.tsx

+ 6 - 2
packages/app/src/components/Page/FixPageGrantAlert.tsx

@@ -9,7 +9,7 @@ import { toastError, toastSuccess } from '~/client/util/apiNotification';
 import { apiv3Put } from '~/client/util/apiv3-client';
 import { PageGrant, IPageGrantData } from '~/interfaces/page';
 import { IRecordApplicableGrant, IResIsGrantNormalizedGrantData } from '~/interfaces/page-grant';
-import { useCurrentPageId, useHasParent } from '~/stores/context';
+import { useCurrentPageId, useIsGuestUser, useHasParent } from '~/stores/context';
 import { useSWRxApplicableGrant, useSWRxIsGrantNormalized } from '~/stores/page';
 
 type ModalProps = {
@@ -231,12 +231,16 @@ const FixPageGrantModal = (props: ModalProps): JSX.Element => {
 const FixPageGrantAlert = (): JSX.Element => {
   const { t } = useTranslation();
 
+  const { data: isGuestUser } = useIsGuestUser();
+
   const [isOpen, setOpen] = useState<boolean>(false);
 
   const { data: pageId } = useCurrentPageId();
   const { data: hasParent } = useHasParent();
   const { data: dataIsGrantNormalized } = useSWRxIsGrantNormalized(pageId);
-  const { data: dataApplicableGrant } = useSWRxApplicableGrant(pageId);
+
+  const shouldFetchApplicableGrant = !isGuestUser;
+  const { data: dataApplicableGrant } = useSWRxApplicableGrant(shouldFetchApplicableGrant ? pageId : null);
 
   // Dependencies
   if (!hasParent) {