Skip to content

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

feat(notifications): provide a way to turn off sticky notifications (#4010)

virtuacoplennyac02a17943bf
diff --git a/interface_config.js b/interface_config.js
index d8222658b9..1778753215 100644
--- a/interface_config.js
+++ b/interface_config.js
@@ -193,7 +193,14 @@ var interfaceConfig = {
/**
* Specify the Android app package name.
*/
- // ANDROID_APP_PACKAGE: 'org.jitsi.meet'
+ // ANDROID_APP_PACKAGE: 'org.jitsi.meet',
+
+ /**
+ * Override the behavior of some notifications to remain displayed until
+ * explicitly dismissed through a user action. The value is how long, in
+ * milliseconds, those notifications should remain displayed.
+ */
+ // ENFORCE_NOTIFICATION_AUTO_DISMISS_TIMEOUT: 15000,
};
/* eslint-enable no-unused-vars, no-var, max-len */
diff --git a/react/features/notifications/components/AbstractNotificationsContainer.js b/react/features/notifications/components/AbstractNotificationsContainer.js
index 7777f0c4dc..c72b027987 100644
--- a/react/features/notifications/components/AbstractNotificationsContainer.js
+++ b/react/features/notifications/components/AbstractNotificationsContainer.js
@@ -13,12 +13,20 @@ export type Props = {
*/
_notifications: Array<Object>,
+ /**
+ * The length, in milliseconds, to use as a default timeout for all
+ * dismissable timeouts that do not have a timeout specified.
+ */
+ autoDismissTimeout: number,
+
/**
* Invoked to update the redux store in order to remove notifications.
*/
dispatch: Function
};
+declare var interfaceConfig: Object;
+
/**
* Abstract class for {@code NotificationsContainer} component.
*/
@@ -78,7 +86,7 @@ export default class AbstractNotificationsContainer<P: Props>
* @private
*/
_manageDismissTimeout(prevProps: ?P) {
- const { _notifications } = this.props;
+ const { _notifications, autoDismissTimeout } = this.props;
if (_notifications.length) {
const notification = _notifications[0];
@@ -90,14 +98,18 @@ export default class AbstractNotificationsContainer<P: Props>
if (notification !== previousNotification) {
this._clearNotificationDismissTimeout();
- if (notification) {
- const { timeout, uid } = notification;
+ if (notification
+ && (notification.timeout
+ || typeof autoDismissTimeout === 'number')
+ && notification.props.isDismissAllowed !== false) {
+ const {
+ timeout = autoDismissTimeout,
+ uid
+ } = notification;
this._notificationDismissTimeout = setTimeout(() => {
// Perform a no-op if a timeout is not specified.
- if (Number.isInteger(timeout)) {
- this._onDismissed(uid);
- }
+ this._onDismissed(uid);
}, timeout);
}
}
@@ -168,6 +180,9 @@ export function _abstractMapStateToProps(state: Object) {
const _visible = areThereNotifications(state);
return {
- _notifications: _visible ? notifications : []
+ _notifications: _visible ? notifications : [],
+ autoDismissTimeout: typeof interfaceConfig === 'undefined'
+ ? undefined // Ignore for the case of mobile
+ : interfaceConfig.ENFORCE_NOTIFICATION_AUTO_DISMISS_TIMEOUT
};
}