kaori 4 лет назад
Родитель
Сommit
d93b2441de

+ 2 - 39
packages/app/src/components/InAppNotification/AllInAppNotifications.tsx

@@ -1,58 +1,21 @@
-import React, { FC, useState, useEffect } from 'react';
+import React, { FC } from 'react';
 
 import AppContainer from '../../client/services/AppContainer';
-import loggerFactory from '~/utils/logger';
 
 import InAppNotificationList from './InAppNotificationList';
 import { withUnstatedContainers } from '../UnstatedUtils';
 import { useSWRxInAppNotifications } from '../../stores/in-app-notification';
 
-const logger = loggerFactory('growi:ALlInAppnotification');
-
 type Props = {
   appContainer: AppContainer,
 
 };
 
 const AllInAppNotifications: FC<Props> = (props: Props) => {
-  const { appContainer } = props;
   // const [notifications, setNotifications] = useState([]);
   const limit = 6;
-  console.log('useSWRxInAppNotification_notifications', inAppNotificationdata);
-  const { data: inAppNotificationData, error, mutate } = useSWRxInAppNotifications(limit);
-
-  const [isLoaded, setIsLoaded] = useState(false);
-
-
-  // useEffect(() => {
-  //   fetchNotificationList();
-  // }, []);
-
-
-  // const fetchNotificationList = async() => {
-  // const limit = 6;
-  // try {
-  // const paginationResult = await appContainer.apiv3Get('/in-app-notification/list', { limit });
-
-  // setNotifications(paginationResult.data.docs);
-  //     setIsLoaded(true);
-  //   }
-  //   catch (err) {
-  //     logger.error(err);
-  //   }
-  // };
-
-  // if (inAppNotificationData == null) {
-  //   return (
-  //     <div className="wiki">
-  //       <div className="text-muted text-center">
-  //         <i className="fa fa-2x fa-spinner fa-pulse mr-1"></i>
-  //       </div>
-  //     </div>
-  //   );
-  // }
+  const { data: inAppNotificationData } = useSWRxInAppNotifications(limit);
 
-  // const notifications = inAppNotificationData.docs;
   return (
     <InAppNotificationList inAppNotificationData={inAppNotificationData} />
   );

+ 1 - 23
packages/app/src/components/InAppNotification/InAppNotificationDropdown.tsx

@@ -21,11 +21,9 @@ const InAppNotificationDropdown: FC<Props> = (props: Props) => {
   const { appContainer } = props;
 
   const [count, setCount] = useState(0);
-  const [isLoaded, setIsLoaded] = useState(false);
-  // const [notifications, setNotifications] = useState([]);
   const [isOpen, setIsOpen] = useState(false);
   const limit = 6;
-  const { data: inAppNotificationData, error, mutate } = useSWRxInAppNotifications(limit);
+  const { data: inAppNotificationData } = useSWRxInAppNotifications(limit);
 
   useEffect(() => {
     initializeSocket(props);
@@ -62,22 +60,6 @@ const InAppNotificationDropdown: FC<Props> = (props: Props) => {
     }
   };
 
-  /**
-    * TODO: Fetch notification list by GW-7473
-    */
-  const fetchNotificationList = async() => {
-    const limit = 6;
-    try {
-      // const paginationResult = await appContainer.apiv3Get('/in-app-notification/list', { limit });
-
-      // setNotifications(paginationResult.data.docs);
-      setIsLoaded(true);
-    }
-    catch (err) {
-      logger.error(err);
-    }
-  };
-
   const toggleDropdownHandler = () => {
     if (isOpen === false && count > 0) {
       updateNotificationStatus();
@@ -85,10 +67,6 @@ const InAppNotificationDropdown: FC<Props> = (props: Props) => {
 
     const newIsOpenState = !isOpen;
     setIsOpen(newIsOpenState);
-
-    if (newIsOpenState === true) {
-      fetchNotificationList();
-    }
   };
 
   /**

+ 0 - 6
packages/app/src/components/InAppNotification/InAppNotificationList.tsx

@@ -6,12 +6,10 @@ import { InAppNotification } from './InAppNotification';
 
 type Props = {
   inAppNotificationData: PaginateResult<IInAppNotification>;
-  // isLoaded: boolean;
 };
 
 const InAppNotificationList: FC<Props> = (props: Props) => {
   const { inAppNotificationData } = props;
-  // console.log('notifications_InAppNotificationList', notifications);
 
   if (inAppNotificationData == null) {
     return (
@@ -64,10 +62,6 @@ const InAppNotificationList: FC<Props> = (props: Props) => {
     return <>{notificationList}</>;
   };
 
-
-  // if (!props.isLoaded) {
-  //   return <RenderUnLoadedInAppNotification />;
-  // }
   return <RenderInAppNotificationList />;
 };