You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // @flow
  2. import { MODERATION_NOTIFICATIONS } from '../av-moderation/constants';
  3. import { MEDIA_TYPE } from '../base/media';
  4. import { toState } from '../base/redux';
  5. declare var interfaceConfig: Object;
  6. /**
  7. * Tells whether or not the notifications are enabled and if there are any
  8. * notifications to be displayed based on the current Redux state.
  9. *
  10. * @param {Object|Function} stateful - The redux store state.
  11. * @returns {boolean}
  12. */
  13. export function areThereNotifications(stateful: Object | Function) {
  14. const state = toState(stateful);
  15. const { enabled, notifications } = state['features/notifications'];
  16. return enabled && notifications.length > 0;
  17. }
  18. /**
  19. * Tells whether join/leave notifications are enabled in interface_config.
  20. *
  21. * @returns {boolean}
  22. */
  23. export function joinLeaveNotificationsDisabled() {
  24. return Boolean(typeof interfaceConfig !== 'undefined' && interfaceConfig?.DISABLE_JOIN_LEAVE_NOTIFICATIONS);
  25. }
  26. /**
  27. * Returns whether or not the moderation notification for the given type is displayed.
  28. *
  29. * @param {MEDIA_TYPE} mediaType - The media type to check.
  30. * @param {Object | Function} stateful - The redux store state.
  31. * @returns {boolean}
  32. */
  33. export function isModerationNotificationDisplayed(mediaType: MEDIA_TYPE, stateful: Object | Function) {
  34. const state = toState(stateful);
  35. const { notifications } = state['features/notifications'];
  36. return Boolean(notifications.find(n => n.uid === MODERATION_NOTIFICATIONS[mediaType]));
  37. }