@etsoo/notificationbase 1.1.50 → 1.1.51

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -57,9 +57,7 @@ class NotificationContainer {
57
57
  const { timespan, onDismiss } = notification;
58
58
  notification.onDismiss = () => {
59
59
  // Remove from the collection
60
- const index = alignItems.findIndex((item) => item.id === notification.id);
61
- if (index > -1)
62
- alignItems.splice(index, 1);
60
+ alignItems.remove((n) => n.id === notification.id);
63
61
  // Call the registered callback
64
62
  this.doRegister(notification, true);
65
63
  // Custom onDismiss callback
@@ -99,15 +97,14 @@ class NotificationContainer {
99
97
  for (const align in this.notifications) {
100
98
  // Align items
101
99
  const items = this.notifications[align];
102
- // Loop to remove closed item
103
- const len = items.length - 1;
104
- for (let n = len; n >= 0; n--) {
105
- const notification = items[n];
106
- if (!notification.open) {
107
- notification.dispose();
108
- items.splice(n, 1);
100
+ // Remove closed items
101
+ items.remove((n) => {
102
+ if (!n.open) {
103
+ n.dispose();
104
+ return true;
109
105
  }
110
- }
106
+ return false;
107
+ });
111
108
  }
112
109
  }
113
110
  /**
@@ -54,9 +54,7 @@ export class NotificationContainer {
54
54
  const { timespan, onDismiss } = notification;
55
55
  notification.onDismiss = () => {
56
56
  // Remove from the collection
57
- const index = alignItems.findIndex((item) => item.id === notification.id);
58
- if (index > -1)
59
- alignItems.splice(index, 1);
57
+ alignItems.remove((n) => n.id === notification.id);
60
58
  // Call the registered callback
61
59
  this.doRegister(notification, true);
62
60
  // Custom onDismiss callback
@@ -96,15 +94,14 @@ export class NotificationContainer {
96
94
  for (const align in this.notifications) {
97
95
  // Align items
98
96
  const items = this.notifications[align];
99
- // Loop to remove closed item
100
- const len = items.length - 1;
101
- for (let n = len; n >= 0; n--) {
102
- const notification = items[n];
103
- if (!notification.open) {
104
- notification.dispose();
105
- items.splice(n, 1);
97
+ // Remove closed items
98
+ items.remove((n) => {
99
+ if (!n.open) {
100
+ n.dispose();
101
+ return true;
106
102
  }
107
- }
103
+ return false;
104
+ });
108
105
  }
109
106
  }
110
107
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/notificationbase",
3
- "version": "1.1.50",
3
+ "version": "1.1.51",
4
4
  "description": "TypeScript notification component for extending with all features described and partially implemented",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/mjs/index.js",
@@ -52,7 +52,7 @@
52
52
  },
53
53
  "homepage": "https://github.com/ETSOO/NotificationBase#readme",
54
54
  "dependencies": {
55
- "@etsoo/shared": "^1.2.49"
55
+ "@etsoo/shared": "^1.2.50"
56
56
  },
57
57
  "devDependencies": {
58
58
  "@babel/core": "^7.25.8",
@@ -278,10 +278,7 @@ export abstract class NotificationContainer<UI, C extends NotificationCallProps>
278
278
  const { timespan, onDismiss } = notification;
279
279
  notification.onDismiss = () => {
280
280
  // Remove from the collection
281
- const index = alignItems.findIndex(
282
- (item) => item.id === notification.id
283
- );
284
- if (index > -1) alignItems.splice(index, 1);
281
+ alignItems.remove((n) => n.id === notification.id);
285
282
 
286
283
  // Call the registered callback
287
284
  this.doRegister(notification, true);
@@ -326,15 +323,14 @@ export abstract class NotificationContainer<UI, C extends NotificationCallProps>
326
323
  // Align items
327
324
  const items = this.notifications[align];
328
325
 
329
- // Loop to remove closed item
330
- const len = items.length - 1;
331
- for (let n = len; n >= 0; n--) {
332
- const notification = items[n];
333
- if (!notification.open) {
334
- notification.dispose();
335
- items.splice(n, 1);
326
+ // Remove closed items
327
+ items.remove((n) => {
328
+ if (!n.open) {
329
+ n.dispose();
330
+ return true;
336
331
  }
337
- }
332
+ return false;
333
+ });
338
334
  }
339
335
  }
340
336