From 7341c7bf843c6ad5c596fa535a491c07e5a21c6a Mon Sep 17 00:00:00 2001 From: Leonard Kim Date: Mon, 11 Dec 2017 10:33:09 -0800 Subject: [PATCH] ref(notifications): stop passing around Notifications component Passing around of the component was used when there were two independent Notification components. Now that there is only one Notification component, it is not necessary to pass around the component. --- modules/UI/util/MessageHandler.js | 18 +++++++----------- react/features/base/participants/actions.js | 7 ++----- react/features/notifications/actions.js | 11 +++-------- .../components/NotificationsContainer.web.js | 3 ++- react/features/videosipgw/middleware.js | 14 ++++++-------- 5 files changed, 20 insertions(+), 33 deletions(-) diff --git a/modules/UI/util/MessageHandler.js b/modules/UI/util/MessageHandler.js index 2e9a63fcb..c6c8d736d 100644 --- a/modules/UI/util/MessageHandler.js +++ b/modules/UI/util/MessageHandler.js @@ -4,7 +4,6 @@ const logger = require('jitsi-meet-logger').getLogger(__filename); import jitsiLocalStorage from '../../util/JitsiLocalStorage'; import { - Notification, showErrorNotification, showNotification, showWarningNotification @@ -493,16 +492,13 @@ const messageHandler = { messageKey, messageArguments, timeout = 2500) { - APP.store.dispatch( - showNotification( - Notification, - { - descriptionArguments: messageArguments, - descriptionKey: messageKey, - titleKey: displayNameKey, - title: displayName - }, - timeout)); + APP.store.dispatch(showNotification({ + descriptionArguments: messageArguments, + descriptionKey: messageKey, + titleKey: displayNameKey, + title: displayName + }, + timeout)); }, /** diff --git a/react/features/base/participants/actions.js b/react/features/base/participants/actions.js index 41b2d2bb2..f3bbe98f0 100644 --- a/react/features/base/participants/actions.js +++ b/react/features/base/participants/actions.js @@ -2,7 +2,7 @@ import throttle from 'lodash/throttle'; -import { Notification, showNotification } from '../../notifications'; +import { showNotification } from '../../notifications'; import { DOMINANT_SPEAKER_CHANGED, @@ -374,10 +374,7 @@ const _throttledNotifyParticipantConnected = throttle(dispatch => { if (notificationProps) { dispatch( - showNotification( - Notification, - notificationProps, - 2500)); + showNotification(notificationProps, 2500)); } joinedParticipantsNames = []; diff --git a/react/features/notifications/actions.js b/react/features/notifications/actions.js index 164d633dc..95164aabe 100644 --- a/react/features/notifications/actions.js +++ b/react/features/notifications/actions.js @@ -3,7 +3,6 @@ import { SET_NOTIFICATIONS_ENABLED, SHOW_NOTIFICATION } from './actionTypes'; -import { Notification } from './components'; import { NOTIFICATION_TYPE } from './constants'; @@ -47,7 +46,7 @@ export function setNotificationsEnabled(enabled) { * @returns {Object} */ export function showErrorNotification(props) { - return showNotification(Notification, { + return showNotification({ ...props, appearance: NOTIFICATION_TYPE.ERROR }); @@ -56,23 +55,19 @@ export function showErrorNotification(props) { /** * Queues a notification for display. * - * @param {ReactComponent} component - The notification component to be - * displayed. * @param {Object} props - The props needed to show the notification component. * @param {number} timeout - How long the notification should display before * automatically being hidden. * @returns {{ * type: SHOW_NOTIFICATION, - * component: ReactComponent, * props: Object, * timeout: number, * uid: number * }} */ -export function showNotification(component, props = {}, timeout) { +export function showNotification(props = {}, timeout) { return { type: SHOW_NOTIFICATION, - component, props, timeout, uid: window.Date.now() @@ -86,7 +81,7 @@ export function showNotification(component, props = {}, timeout) { * @returns {Object} */ export function showWarningNotification(props) { - return showNotification(Notification, { + return showNotification({ ...props, appearance: NOTIFICATION_TYPE.WARNING }); diff --git a/react/features/notifications/components/NotificationsContainer.web.js b/react/features/notifications/components/NotificationsContainer.web.js index 481ccbd9e..9f3b78789 100644 --- a/react/features/notifications/components/NotificationsContainer.web.js +++ b/react/features/notifications/components/NotificationsContainer.web.js @@ -5,6 +5,8 @@ import { connect } from 'react-redux'; import { hideNotification } from '../actions'; +import { Notification } from './'; + /** * Implements a React {@link Component} which displays notifications and handles * automatic dismissmal after a notification is shown for a defined timeout @@ -142,7 +144,6 @@ class NotificationsContainer extends Component { } return _notifications.map(notification => { - const Notification = notification.component; const { props, uid } = notification; // The id attribute is necessary as {@code FlagGroup} looks for diff --git a/react/features/videosipgw/middleware.js b/react/features/videosipgw/middleware.js index 3bd0d32fc..f29a3f7fd 100644 --- a/react/features/videosipgw/middleware.js +++ b/react/features/videosipgw/middleware.js @@ -12,7 +12,6 @@ import { } from '../base/lib-jitsi-meet'; import { MiddlewareRegistry } from '../base/redux'; import { - Notification, showErrorNotification, showNotification, showWarningNotification @@ -158,13 +157,12 @@ function _sessionStateChanged( event: Object) { switch (event.newState) { case JitsiSIPVideoGWStatus.STATE_PENDING: { - return showNotification( - Notification, { - titleKey: 'videoSIPGW.pending', - titleArguments: { - displayName: event.displayName - } - }, 2000); + return showNotification({ + titleKey: 'videoSIPGW.pending', + titleArguments: { + displayName: event.displayName + } + }, 2000); } case JitsiSIPVideoGWStatus.STATE_FAILED: { return showErrorNotification({