Skip to content

Commit 17a7e90

Browse files
committed
build
1 parent 321fe4b commit 17a7e90

File tree

6 files changed

+76
-44
lines changed

6 files changed

+76
-44
lines changed

dist/react-notification-system-redux.js

Lines changed: 37 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ exports.error = error;
1111
exports.warning = warning;
1212
exports.info = info;
1313
exports.hide = hide;
14+
exports.removeAll = removeAll;
1415

1516
var _const = require('./const');
1617

@@ -63,12 +64,17 @@ function hide(uid) {
6364
};
6465
}
6566

67+
function removeAll() {
68+
return { type: _const.RNS_REMOVE_ALL_NOTIFICATIONS };
69+
}
70+
6671
},{"./const":2}],2:[function(require,module,exports){
6772
Object.defineProperty(exports, "__esModule", {
6873
value: true
6974
});
7075
var RNS_SHOW_NOTIFICATION = exports.RNS_SHOW_NOTIFICATION = 'RNS_SHOW_NOTIFICATION';
7176
var RNS_HIDE_NOTIFICATION = exports.RNS_HIDE_NOTIFICATION = 'RNS_HIDE_NOTIFICATION';
77+
var RNS_REMOVE_ALL_NOTIFICATIONS = exports.RNS_REMOVE_ALL_NOTIFICATIONS = 'RNS_REMOVE_ALL_NOTIFICATIONS';
7278

7379
},{}],3:[function(require,module,exports){
7480
(function (global){
@@ -133,27 +139,35 @@ var Notifications = function (_React$Component) {
133139
var notificationIds = notifications.map(function (notification) {
134140
return notification.uid;
135141
});
136-
137-
// Get all active notifications from react-notification-system
138-
/// and remove all where uid is not found in the reducer
139-
(this.system().state.notifications || []).forEach(function (notification) {
140-
if (notificationIds.indexOf(notification.uid) < 0) {
141-
_this2.system().removeNotification(notification.uid);
142-
}
143-
});
144-
145-
notifications.forEach(function (notification) {
146-
_this2.system().addNotification(_extends({}, notification, {
147-
onRemove: function () {
148-
function onRemove() {
149-
_this2.context.store.dispatch(actions.hide(notification.uid));
150-
notification.onRemove && notification.onRemove();
151-
}
152-
153-
return onRemove;
154-
}()
155-
}));
156-
});
142+
var systemNotifications = this.system().state.notifications || [];
143+
144+
if (notifications.length > 0) {
145+
// Get all active notifications from react-notification-system
146+
/// and remove all where uid is not found in the reducer
147+
systemNotifications.forEach(function (notification) {
148+
if (notificationIds.indexOf(notification.uid) < 0) {
149+
console.log('removing', _this2.system().state.notifications);
150+
_this2.system().removeNotification(notification.uid);
151+
}
152+
});
153+
154+
notifications.forEach(function (notification) {
155+
_this2.system().addNotification(_extends({}, notification, {
156+
onRemove: function () {
157+
function onRemove() {
158+
_this2.context.store.dispatch(actions.hide(notification.uid));
159+
notification.onRemove && notification.onRemove();
160+
}
161+
162+
return onRemove;
163+
}()
164+
}));
165+
});
166+
}
167+
168+
if (this.props.notifications !== notifications && notifications.length === 0) {
169+
this.system().clearNotifications();
170+
}
157171
}
158172

159173
return componentWillReceiveProps;
@@ -234,6 +248,8 @@ function Notifications() {
234248
return state.filter(function (notification) {
235249
return notification.uid !== action.uid;
236250
});
251+
case _const.RNS_REMOVE_ALL_NOTIFICATIONS:
252+
return [];
237253
}
238254
return state;
239255
}

dist/react-notification-system-redux.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/actions.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ exports.error = error;
1010
exports.warning = warning;
1111
exports.info = info;
1212
exports.hide = hide;
13+
exports.removeAll = removeAll;
1314

1415
var _const = require('./const');
1516

@@ -60,4 +61,8 @@ function hide(uid) {
6061
type: _const.RNS_HIDE_NOTIFICATION,
6162
uid: uid
6263
};
64+
}
65+
66+
function removeAll() {
67+
return { type: _const.RNS_REMOVE_ALL_NOTIFICATIONS };
6368
}

lib/const.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ Object.defineProperty(exports, "__esModule", {
22
value: true
33
});
44
var RNS_SHOW_NOTIFICATION = exports.RNS_SHOW_NOTIFICATION = 'RNS_SHOW_NOTIFICATION';
5-
var RNS_HIDE_NOTIFICATION = exports.RNS_HIDE_NOTIFICATION = 'RNS_HIDE_NOTIFICATION';
5+
var RNS_HIDE_NOTIFICATION = exports.RNS_HIDE_NOTIFICATION = 'RNS_HIDE_NOTIFICATION';
6+
var RNS_REMOVE_ALL_NOTIFICATIONS = exports.RNS_REMOVE_ALL_NOTIFICATIONS = 'RNS_REMOVE_ALL_NOTIFICATIONS';

lib/notifications.js

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -59,27 +59,35 @@ var Notifications = function (_React$Component) {
5959
var notificationIds = notifications.map(function (notification) {
6060
return notification.uid;
6161
});
62-
63-
// Get all active notifications from react-notification-system
64-
/// and remove all where uid is not found in the reducer
65-
(this.system().state.notifications || []).forEach(function (notification) {
66-
if (notificationIds.indexOf(notification.uid) < 0) {
67-
_this2.system().removeNotification(notification.uid);
68-
}
69-
});
70-
71-
notifications.forEach(function (notification) {
72-
_this2.system().addNotification(_extends({}, notification, {
73-
onRemove: function () {
74-
function onRemove() {
75-
_this2.context.store.dispatch(actions.hide(notification.uid));
76-
notification.onRemove && notification.onRemove();
77-
}
78-
79-
return onRemove;
80-
}()
81-
}));
82-
});
62+
var systemNotifications = this.system().state.notifications || [];
63+
64+
if (notifications.length > 0) {
65+
// Get all active notifications from react-notification-system
66+
/// and remove all where uid is not found in the reducer
67+
systemNotifications.forEach(function (notification) {
68+
if (notificationIds.indexOf(notification.uid) < 0) {
69+
console.log('removing', _this2.system().state.notifications);
70+
_this2.system().removeNotification(notification.uid);
71+
}
72+
});
73+
74+
notifications.forEach(function (notification) {
75+
_this2.system().addNotification(_extends({}, notification, {
76+
onRemove: function () {
77+
function onRemove() {
78+
_this2.context.store.dispatch(actions.hide(notification.uid));
79+
notification.onRemove && notification.onRemove();
80+
}
81+
82+
return onRemove;
83+
}()
84+
}));
85+
});
86+
}
87+
88+
if (this.props.notifications !== notifications && notifications.length === 0) {
89+
this.system().clearNotifications();
90+
}
8391
}
8492

8593
return componentWillReceiveProps;

lib/reducer.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ function Notifications() {
2727
return state.filter(function (notification) {
2828
return notification.uid !== action.uid;
2929
});
30+
case _const.RNS_REMOVE_ALL_NOTIFICATIONS:
31+
return [];
3032
}
3133
return state;
3234
}

0 commit comments

Comments
 (0)