|
@@ -5,6 +5,7 @@ import loggerFactory from '~/utils/logger';
|
|
|
|
|
|
|
|
import InAppNotificationList from './InAppNotificationList';
|
|
import InAppNotificationList from './InAppNotificationList';
|
|
|
import { withUnstatedContainers } from '../UnstatedUtils';
|
|
import { withUnstatedContainers } from '../UnstatedUtils';
|
|
|
|
|
+import { useSWRxInAppNotifications } from '../../stores/in-app-notification';
|
|
|
|
|
|
|
|
const logger = loggerFactory('growi:ALlInAppnotification');
|
|
const logger = loggerFactory('growi:ALlInAppnotification');
|
|
|
|
|
|
|
@@ -15,20 +16,25 @@ 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 limit = 6;
|
|
|
|
|
+ const { data: inAppNotificationdata, error, mutate } = useSWRxInAppNotifications(limit);
|
|
|
|
|
+ console.log('useSWRxInAppNotification_notifications', inAppNotificationdata);
|
|
|
|
|
+
|
|
|
const [isLoaded, setIsLoaded] = useState(false);
|
|
const [isLoaded, setIsLoaded] = useState(false);
|
|
|
|
|
|
|
|
|
|
+
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
|
fetchNotificationList();
|
|
fetchNotificationList();
|
|
|
}, []);
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
|
|
|
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) {
|
|
@@ -36,6 +42,18 @@ const AllInAppNotifications: FC<Props> = (props: Props) => {
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
+ 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 notifications = inAppNotificationdata.docs;
|
|
|
|
|
+ console.log('notifications!!', notifications);
|
|
|
|
|
+
|
|
|
return (
|
|
return (
|
|
|
<InAppNotificationList notifications={notifications} isLoaded={isLoaded} />
|
|
<InAppNotificationList notifications={notifications} isLoaded={isLoaded} />
|
|
|
);
|
|
);
|