From 5f6b8bc69849152f858546a49b729f128478d4ea Mon Sep 17 00:00:00 2001 From: "Arthur B. Grossi" <32987232+Arthurk12@users.noreply.github.com> Date: Tue, 22 Oct 2024 17:43:00 -0300 Subject: [PATCH] feat: add `bbb_hide_notifications` (#21415) * feat(layout): add `hideNotificationToasts` to notifications bar context Adds the `hideNotificationToasts` property to the notifications bar in the layout context, allowing the notification toasts to be hidden when the property is set to `true`. * feat(layout): add userdata `bbb_hide_notifications` Introduces join userdata parameter `bbb_hide_notifications` that prevents the rendering of all notification toasts in the client. --- .../imports/ui/components/app/component.jsx | 6 ++++-- .../imports/ui/components/app/container.jsx | 3 +++ .../imports/ui/components/layout/context.jsx | 18 ++++++++++++++++++ .../imports/ui/components/layout/enums.js | 1 + .../imports/ui/components/layout/initState.js | 1 + .../ui/components/layout/layoutTypes.ts | 1 + .../imports/ui/components/layout/observer.tsx | 5 +++++ 7 files changed, 33 insertions(+), 2 deletions(-) diff --git a/bigbluebutton-html5/imports/ui/components/app/component.jsx b/bigbluebutton-html5/imports/ui/components/app/component.jsx index c0b6f2b0b8..fed48cff88 100644 --- a/bigbluebutton-html5/imports/ui/components/app/component.jsx +++ b/bigbluebutton-html5/imports/ui/components/app/component.jsx @@ -107,6 +107,7 @@ const intlMessages = defineMessages({ const propTypes = { darkTheme: PropTypes.bool.isRequired, + hideNotificationToasts: PropTypes.bool.isRequired, }; class App extends Component { @@ -251,6 +252,7 @@ class App extends Component { intl, pluginConfig, genericMainContentId, + hideNotificationToasts, } = this.props; const { @@ -318,7 +320,7 @@ class App extends Component { ) : null} {this.renderAudioCaptions()} - + { !hideNotificationToasts && } - + { !hideNotificationToasts && } diff --git a/bigbluebutton-html5/imports/ui/components/app/container.jsx b/bigbluebutton-html5/imports/ui/components/app/container.jsx index 474431fe0c..2a6f4d64a6 100755 --- a/bigbluebutton-html5/imports/ui/components/app/container.jsx +++ b/bigbluebutton-html5/imports/ui/components/app/container.jsx @@ -54,6 +54,7 @@ const AppContainer = (props) => { const captionsStyle = layoutSelectOutput((i) => i.captions); const presentation = layoutSelectInput((i) => i.presentation); const sharedNotesInput = layoutSelectInput((i) => i.sharedNotes); + const { hideNotificationToasts } = layoutSelectInput((i) => i.notificationsBar); const setSpeechOptions = useSetSpeechOptions(); const { data: pinnedPadData } = useDeduplicatedSubscription(PINNED_PAD_SUBSCRIPTION); @@ -105,6 +106,8 @@ const AppContainer = (props) => { shouldShowPresentation, genericMainContentId: genericMainContent.genericContentId, audioCaptions: , + hideNotificationToasts: hideNotificationToasts + || getFromUserSettings('bbb_hide_notifications', false), darkTheme, }} {...props} diff --git a/bigbluebutton-html5/imports/ui/components/layout/context.jsx b/bigbluebutton-html5/imports/ui/components/layout/context.jsx index 5b8dc93777..6f481f8b10 100644 --- a/bigbluebutton-html5/imports/ui/components/layout/context.jsx +++ b/bigbluebutton-html5/imports/ui/components/layout/context.jsx @@ -205,6 +205,24 @@ const reducer = (state, action) => { }; } + // NOTIFICATION TOASTS + case ACTIONS.SET_HIDE_NOTIFICATION_TOASTS: { + const { notificationsBar } = state.input; + if (notificationsBar.hideNotificationToasts === action.value) { + return state; + } + return { + ...state, + input: { + ...state.input, + notificationsBar: { + ...notificationsBar, + hideNotificationToasts: action.value, + }, + }, + }; + } + // NAV BAR case ACTIONS.SET_HAS_NAVBAR: { diff --git a/bigbluebutton-html5/imports/ui/components/layout/enums.js b/bigbluebutton-html5/imports/ui/components/layout/enums.js index 58a701eea9..12a74f1ac3 100644 --- a/bigbluebutton-html5/imports/ui/components/layout/enums.js +++ b/bigbluebutton-html5/imports/ui/components/layout/enums.js @@ -53,6 +53,7 @@ export const ACTIONS = { SET_HAS_BANNER_BAR: 'setHasBannerBar', SET_HAS_NOTIFICATIONS_BAR: 'setHasNotificationsBar', + SET_HIDE_NOTIFICATION_TOASTS: 'setHideNotificationToasts', SET_HAS_NAVBAR: 'setHasNavBar', SET_NAVBAR_OUTPUT: 'setNavBarOutput', diff --git a/bigbluebutton-html5/imports/ui/components/layout/initState.js b/bigbluebutton-html5/imports/ui/components/layout/initState.js index b86e19aaf5..aeb6fecada 100644 --- a/bigbluebutton-html5/imports/ui/components/layout/initState.js +++ b/bigbluebutton-html5/imports/ui/components/layout/initState.js @@ -14,6 +14,7 @@ export const INITIAL_INPUT_STATE = { }, notificationsBar: { hasNotification: false, + hideNotificationToasts: false, }, navBar: { hasNavBar: true, diff --git a/bigbluebutton-html5/imports/ui/components/layout/layoutTypes.ts b/bigbluebutton-html5/imports/ui/components/layout/layoutTypes.ts index dee1f13885..868d9b9683 100644 --- a/bigbluebutton-html5/imports/ui/components/layout/layoutTypes.ts +++ b/bigbluebutton-html5/imports/ui/components/layout/layoutTypes.ts @@ -108,6 +108,7 @@ interface NavBar { interface NotificationsBar { hasNotification: boolean; + hideNotificationToasts: boolean; } interface Size { diff --git a/bigbluebutton-html5/imports/ui/components/layout/observer.tsx b/bigbluebutton-html5/imports/ui/components/layout/observer.tsx index 355c31207a..a36da541d5 100644 --- a/bigbluebutton-html5/imports/ui/components/layout/observer.tsx +++ b/bigbluebutton-html5/imports/ui/components/layout/observer.tsx @@ -109,6 +109,11 @@ const LayoutObserver: React.FC = () => { value: !getFromUserSettings('bbb_hide_nav_bar', false), }); + layoutContextDispatch({ + type: ACTIONS.SET_HIDE_NOTIFICATION_TOASTS, + value: getFromUserSettings('bbb_hide_notifications', false), + }); + window.addEventListener('localeChanged', () => { layoutContextDispatch({ type: ACTIONS.SET_IS_RTL,