2021-09-15 08:28:44 +00:00
|
|
|
import { MODERATION_NOTIFICATIONS } from '../av-moderation/constants';
|
2022-09-19 07:40:03 +00:00
|
|
|
import { IStateful } from '../base/app/types';
|
|
|
|
import { MediaType } from '../base/media/constants';
|
|
|
|
import { toState } from '../base/redux/functions';
|
2020-01-14 09:41:16 +00:00
|
|
|
|
2019-03-20 20:09:23 +00:00
|
|
|
/**
|
|
|
|
* Tells whether or not the notifications are enabled and if there are any
|
|
|
|
* notifications to be displayed based on the current Redux state.
|
|
|
|
*
|
2022-09-19 07:40:03 +00:00
|
|
|
* @param {IStateful} stateful - The redux store state.
|
2019-03-20 20:09:23 +00:00
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
2022-09-19 07:40:03 +00:00
|
|
|
export function areThereNotifications(stateful: IStateful) {
|
2019-03-20 20:09:23 +00:00
|
|
|
const state = toState(stateful);
|
|
|
|
const { enabled, notifications } = state['features/notifications'];
|
|
|
|
|
|
|
|
return enabled && notifications.length > 0;
|
|
|
|
}
|
2020-01-14 09:41:16 +00:00
|
|
|
|
|
|
|
/**
|
2021-03-16 15:59:33 +00:00
|
|
|
* Tells whether join/leave notifications are enabled in interface_config.
|
2020-01-14 09:41:16 +00:00
|
|
|
*
|
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
|
|
|
export function joinLeaveNotificationsDisabled() {
|
2020-02-04 14:26:36 +00:00
|
|
|
return Boolean(typeof interfaceConfig !== 'undefined' && interfaceConfig?.DISABLE_JOIN_LEAVE_NOTIFICATIONS);
|
2020-01-14 09:41:16 +00:00
|
|
|
}
|
2021-09-15 08:28:44 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns whether or not the moderation notification for the given type is displayed.
|
|
|
|
*
|
|
|
|
* @param {MEDIA_TYPE} mediaType - The media type to check.
|
2022-09-19 07:40:03 +00:00
|
|
|
* @param {IStateful} stateful - The redux store state.
|
2021-09-15 08:28:44 +00:00
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
2022-09-19 07:40:03 +00:00
|
|
|
export function isModerationNotificationDisplayed(mediaType: MediaType, stateful: IStateful) {
|
2021-09-15 08:28:44 +00:00
|
|
|
const state = toState(stateful);
|
|
|
|
|
|
|
|
const { notifications } = state['features/notifications'];
|
|
|
|
|
|
|
|
return Boolean(notifications.find(n => n.uid === MODERATION_NOTIFICATIONS[mediaType]));
|
|
|
|
}
|