瀏覽代碼

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

j8
virtuacoplenny 6 年之前
父節點
當前提交
ac02a17943
沒有連結到貢獻者的電子郵件帳戶。
共有 2 個檔案被更改,包括 30 行新增8 行删除
  1. 8
    1
      interface_config.js
  2. 22
    7
      react/features/notifications/components/AbstractNotificationsContainer.js

+ 8
- 1
interface_config.js 查看文件

193
     /**
193
     /**
194
      * Specify the Android app package name.
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
 /* eslint-enable no-unused-vars, no-var, max-len */
206
 /* eslint-enable no-unused-vars, no-var, max-len */

+ 22
- 7
react/features/notifications/components/AbstractNotificationsContainer.js 查看文件

13
      */
13
      */
14
     _notifications: Array<Object>,
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
      * Invoked to update the redux store in order to remove notifications.
23
      * Invoked to update the redux store in order to remove notifications.
18
      */
24
      */
19
     dispatch: Function
25
     dispatch: Function
20
 };
26
 };
21
 
27
 
28
+declare var interfaceConfig: Object;
29
+
22
 /**
30
 /**
23
  * Abstract class for {@code NotificationsContainer} component.
31
  * Abstract class for {@code NotificationsContainer} component.
24
  */
32
  */
78
      * @private
86
      * @private
79
      */
87
      */
80
     _manageDismissTimeout(prevProps: ?P) {
88
     _manageDismissTimeout(prevProps: ?P) {
81
-        const { _notifications } = this.props;
89
+        const { _notifications, autoDismissTimeout } = this.props;
82
 
90
 
83
         if (_notifications.length) {
91
         if (_notifications.length) {
84
             const notification = _notifications[0];
92
             const notification = _notifications[0];
90
             if (notification !== previousNotification) {
98
             if (notification !== previousNotification) {
91
                 this._clearNotificationDismissTimeout();
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
                     this._notificationDismissTimeout = setTimeout(() => {
110
                     this._notificationDismissTimeout = setTimeout(() => {
97
                         // Perform a no-op if a timeout is not specified.
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
                     }, timeout);
113
                     }, timeout);
102
                 }
114
                 }
103
             }
115
             }
168
     const _visible = areThereNotifications(state);
180
     const _visible = areThereNotifications(state);
169
 
181
 
170
     return {
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
 }

Loading…
取消
儲存