|
@@ -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
|
}
|