|
|
@@ -51,18 +51,40 @@ export default class AbstractNotificationsContainer<P: Props>
|
|
51
|
51
|
this._onDismissed = this._onDismissed.bind(this);
|
|
52
|
52
|
}
|
|
53
|
53
|
|
|
|
54
|
+ /**
|
|
|
55
|
+ * Sets a timeout for the first notification (if applicable).
|
|
|
56
|
+ *
|
|
|
57
|
+ * @inheritdoc
|
|
|
58
|
+ */
|
|
|
59
|
+ componentDidMount() {
|
|
|
60
|
+ // Set the initial dismiss timeout (if any)
|
|
|
61
|
+ this._manageDismissTimeout();
|
|
|
62
|
+ }
|
|
|
63
|
+
|
|
54
|
64
|
/**
|
|
55
|
65
|
* Sets a timeout if the currently displayed notification has changed.
|
|
56
|
66
|
*
|
|
57
|
67
|
* @inheritdoc
|
|
58
|
68
|
*/
|
|
59
|
69
|
componentDidUpdate(prevProps: P) {
|
|
|
70
|
+ this._manageDismissTimeout(prevProps);
|
|
|
71
|
+ }
|
|
|
72
|
+
|
|
|
73
|
+ /**
|
|
|
74
|
+ * Sets/clears the dismiss timeout for the top notification.
|
|
|
75
|
+ *
|
|
|
76
|
+ * @param {P} [prevProps] - The previous properties (if called from
|
|
|
77
|
+ * {@code componentDidUpdate}).
|
|
|
78
|
+ * @returns {void}
|
|
|
79
|
+ * @private
|
|
|
80
|
+ */
|
|
|
81
|
+ _manageDismissTimeout(prevProps: ?P) {
|
|
60
|
82
|
const { _notifications } = this.props;
|
|
61
|
83
|
|
|
62
|
84
|
if (_notifications.length) {
|
|
63
|
85
|
const notification = _notifications[0];
|
|
64
|
86
|
const previousNotification
|
|
65
|
|
- = prevProps._notifications.length
|
|
|
87
|
+ = prevProps && prevProps._notifications.length
|
|
66
|
88
|
? prevProps._notifications[0]
|
|
67
|
89
|
: undefined;
|
|
68
|
90
|
|