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.

functions.ts 1.4KB

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