Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

fix(AbstractNotificationsContainer): dismiss timeout not always set

paweldomas95f684da2f76
diff --git a/react/features/notifications/components/AbstractNotificationsContainer.js b/react/features/notifications/components/AbstractNotificationsContainer.js
index bab80f33aa..276b00a09e 100644
--- a/react/features/notifications/components/AbstractNotificationsContainer.js
+++ b/react/features/notifications/components/AbstractNotificationsContainer.js
@@ -51,18 +51,40 @@ export default class AbstractNotificationsContainer<P: Props>
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;