diff --git a/react/features/notifications/components/AbstractNotificationsContainer.js b/react/features/notifications/components/AbstractNotificationsContainer.js index bab80f33a..276b00a09 100644 --- a/react/features/notifications/components/AbstractNotificationsContainer.js +++ b/react/features/notifications/components/AbstractNotificationsContainer.js @@ -51,18 +51,40 @@ export default class AbstractNotificationsContainer this._onDismissed = this._onDismissed.bind(this); } + /** + * Sets a timeout for the first notification (if applicable). + * + * @inheritdoc + */ + componentDidMount() { + // Set the initial dismiss timeout (if any) + this._manageDismissTimeout(); + } + /** * Sets a timeout if the currently displayed notification has changed. * * @inheritdoc */ componentDidUpdate(prevProps: P) { + this._manageDismissTimeout(prevProps); + } + + /** + * Sets/clears the dismiss timeout for the top notification. + * + * @param {P} [prevProps] - The previous properties (if called from + * {@code componentDidUpdate}). + * @returns {void} + * @private + */ + _manageDismissTimeout(prevProps: ?P) { const { _notifications } = this.props; if (_notifications.length) { const notification = _notifications[0]; const previousNotification - = prevProps._notifications.length + = prevProps && prevProps._notifications.length ? prevProps._notifications[0] : undefined;