index.tsx 1.2 KB

12345678910111213141516171819202122232425262728293031
  1. import type { FC } from 'react';
  2. import type { HasObjectId } from '@growi/core';
  3. import type { IInAppNotification } from '~/interfaces/in-app-notification';
  4. import { usePageBulkExportJobModelNotification } from './PageBulkExportJobModelNotification';
  5. import { usePageModelNotification } from './PageModelNotification';
  6. import { useUserModelNotification } from './UserModelNotification';
  7. export interface ModelNotificationUtils {
  8. Notification: FC
  9. publishOpen?: () => void
  10. clickLink?: string
  11. // Whether actions from clicking notification is disabled or not.
  12. // User can still open the notification when true.
  13. isDisabled?: boolean
  14. }
  15. export const useModelNotification = (notification: IInAppNotification & HasObjectId): ModelNotificationUtils | null => {
  16. const pageModelNotificationUtils = usePageModelNotification(notification);
  17. const userModelNotificationUtils = useUserModelNotification(notification);
  18. const pageBulkExportResultModelNotificationUtils = usePageBulkExportJobModelNotification(notification);
  19. const modelNotificationUtils = pageModelNotificationUtils ?? userModelNotificationUtils ?? pageBulkExportResultModelNotificationUtils;
  20. return modelNotificationUtils;
  21. };