Переглянути джерело

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

j8
virtuacoplenny 6 роки тому
джерело
коміт
ac02a17943
Аккаунт користувача з таким Email не знайдено

+ 8
- 1
interface_config.js Переглянути файл

@@ -193,7 +193,14 @@ var interfaceConfig = {
193 193
     /**
194 194
      * Specify the Android app package name.
195 195
      */
196
-    // ANDROID_APP_PACKAGE: 'org.jitsi.meet'
196
+    // ANDROID_APP_PACKAGE: 'org.jitsi.meet',
197
+
198
+    /**
199
+     * Override the behavior of some notifications to remain displayed until
200
+     * explicitly dismissed through a user action. The value is how long, in
201
+     * milliseconds, those notifications should remain displayed.
202
+     */
203
+    // ENFORCE_NOTIFICATION_AUTO_DISMISS_TIMEOUT: 15000,
197 204
 };
198 205
 
199 206
 /* eslint-enable no-unused-vars, no-var, max-len */

+ 22
- 7
react/features/notifications/components/AbstractNotificationsContainer.js Переглянути файл

@@ -13,12 +13,20 @@ export type Props = {
13 13
      */
14 14
     _notifications: Array<Object>,
15 15
 
16
+    /**
17
+     * The length, in milliseconds, to use as a default timeout for all
18
+     * dismissable timeouts that do not have a timeout specified.
19
+     */
20
+    autoDismissTimeout: number,
21
+
16 22
     /**
17 23
      * Invoked to update the redux store in order to remove notifications.
18 24
      */
19 25
     dispatch: Function
20 26
 };
21 27
 
28
+declare var interfaceConfig: Object;
29
+
22 30
 /**
23 31
  * Abstract class for {@code NotificationsContainer} component.
24 32
  */
@@ -78,7 +86,7 @@ export default class AbstractNotificationsContainer<P: Props>
78 86
      * @private
79 87
      */
80 88
     _manageDismissTimeout(prevProps: ?P) {
81
-        const { _notifications } = this.props;
89
+        const { _notifications, autoDismissTimeout } = this.props;
82 90
 
83 91
         if (_notifications.length) {
84 92
             const notification = _notifications[0];
@@ -90,14 +98,18 @@ export default class AbstractNotificationsContainer<P: Props>
90 98
             if (notification !== previousNotification) {
91 99
                 this._clearNotificationDismissTimeout();
92 100
 
93
-                if (notification) {
94
-                    const { timeout, uid } = notification;
101
+                if (notification
102
+                        && (notification.timeout
103
+                            || typeof autoDismissTimeout === 'number')
104
+                        && notification.props.isDismissAllowed !== false) {
105
+                    const {
106
+                        timeout = autoDismissTimeout,
107
+                        uid
108
+                    } = notification;
95 109
 
96 110
                     this._notificationDismissTimeout = setTimeout(() => {
97 111
                         // Perform a no-op if a timeout is not specified.
98
-                        if (Number.isInteger(timeout)) {
99
-                            this._onDismissed(uid);
100
-                        }
112
+                        this._onDismissed(uid);
101 113
                     }, timeout);
102 114
                 }
103 115
             }
@@ -168,6 +180,9 @@ export function _abstractMapStateToProps(state: Object) {
168 180
     const _visible = areThereNotifications(state);
169 181
 
170 182
     return {
171
-        _notifications: _visible ? notifications : []
183
+        _notifications: _visible ? notifications : [],
184
+        autoDismissTimeout: typeof interfaceConfig === 'undefined'
185
+            ? undefined // Ignore for the case of mobile
186
+            : interfaceConfig.ENFORCE_NOTIFICATION_AUTO_DISMISS_TIMEOUT
172 187
     };
173 188
 }

Завантаження…
Відмінити
Зберегти