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

+ 7 - 7
packages/app/src/components/InAppNotification/AllInAppNotifications.tsx

@@ -1,10 +1,13 @@
 import React, { FC, useState, useEffect } from 'react';
 import React, { FC, useState, useEffect } from 'react';
 
 
 import AppContainer from '../../client/services/AppContainer';
 import AppContainer from '../../client/services/AppContainer';
+import loggerFactory from '~/utils/logger';
 
 
 import InAppNotificationContents from './InAppNotificationContents';
 import InAppNotificationContents from './InAppNotificationContents';
 import { withUnstatedContainers } from '../UnstatedUtils';
 import { withUnstatedContainers } from '../UnstatedUtils';
 
 
+const logger = loggerFactory('growi:ALlInAppnotification');
+
 type Props = {
 type Props = {
   appContainer: AppContainer,
   appContainer: AppContainer,
 
 
@@ -13,31 +16,28 @@ type Props = {
 const AllInAppNotifications: FC<Props> = (props: Props) => {
 const AllInAppNotifications: FC<Props> = (props: Props) => {
   const { appContainer } = props;
   const { appContainer } = props;
   const [notifications, setNotifications] = useState([]);
   const [notifications, setNotifications] = useState([]);
-  // const [isLoaded, setIsLoaded] = useState(false);
+  const [isLoaded, setIsLoaded] = useState(false);
 
 
   useEffect(() => {
   useEffect(() => {
     fetchNotificationList();
     fetchNotificationList();
   }, []);
   }, []);
 
 
 
 
-  /**
-    * TODO: Fetch notification list by GW-7473
-    */
   const fetchNotificationList = async() => {
   const fetchNotificationList = async() => {
     const limit = 6;
     const limit = 6;
     try {
     try {
       const paginationResult = await appContainer.apiv3Get('/in-app-notification/list', { limit });
       const paginationResult = await appContainer.apiv3Get('/in-app-notification/list', { limit });
 
 
       setNotifications(paginationResult.data.docs);
       setNotifications(paginationResult.data.docs);
-      // setIsLoaded(true);
+      setIsLoaded(true);
     }
     }
     catch (err) {
     catch (err) {
-      // logger.error(err);
+      logger.error(err);
     }
     }
   };
   };
 
 
   return (
   return (
-    <InAppNotificationContents notifications={notifications} />
+    <InAppNotificationContents notifications={notifications} isLoaded={isLoaded} />
   );
   );
 };
 };
 
 

+ 4 - 3
packages/app/src/components/InAppNotification/InAppNotificationContents.tsx

@@ -5,6 +5,7 @@ import { InAppNotification } from './InAppNotification';
 
 
 type Props = {
 type Props = {
   notifications: Array<IInAppNotification>;
   notifications: Array<IInAppNotification>;
+  isLoaded: boolean;
 };
 };
 
 
 const InAppNotificationContents: FC<Props> = (props: Props) => {
 const InAppNotificationContents: FC<Props> = (props: Props) => {
@@ -52,9 +53,9 @@ const InAppNotificationContents: FC<Props> = (props: Props) => {
   };
   };
 
 
   const InAppNotificationContents = (): JSX.Element => {
   const InAppNotificationContents = (): JSX.Element => {
-    // if (!isLoaded) {
-    //   return <RenderUnLoadedInAppNotification />;
-    // }
+    if (!props.isLoaded) {
+      return <RenderUnLoadedInAppNotification />;
+    }
     return <RenderInAppNotificationList />;
     return <RenderInAppNotificationList />;
   };
   };
 
 

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

@@ -103,7 +103,7 @@ const InAppNotificationDropdown: FC<Props> = (props: Props) => {
         </button>
         </button>
       </DropdownToggle>
       </DropdownToggle>
       <DropdownMenu className="px-2" right>
       <DropdownMenu className="px-2" right>
-        <InAppNotificationContents notifications={notifications} />
+        <InAppNotificationContents notifications={notifications} isLoaded={isLoaded} />
         <DropdownItem divider />
         <DropdownItem divider />
         {/* TODO: Able to show all notifications by #79317 */}
         {/* TODO: Able to show all notifications by #79317 */}
         <a className="dropdown-item d-flex justify-content-center" href="/me/all-in-app-notifications">See All</a>
         <a className="dropdown-item d-flex justify-content-center" href="/me/all-in-app-notifications">See All</a>