@etsoo/notificationbase 1.1.46 → 1.1.48

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.
@@ -204,13 +204,23 @@ class NotificationContainer {
204
204
  * @param force Force to hide, otherwise, only the last one
205
205
  */
206
206
  hideLoading(force) {
207
- // Deduct to count
208
- this.loadingCount--;
209
- if (force)
207
+ if (this.lastLoading == null) {
208
+ // Reset count when no loading
210
209
  this.loadingCount = 0;
211
- if (this.loadingCount === 0) {
212
- this.lastLoading?.dismiss();
213
- this.lastLoading = undefined;
210
+ }
211
+ else {
212
+ // Deduct to count
213
+ // Avoid negative result (-1)
214
+ if (this.loadingCount > 0) {
215
+ this.loadingCount--;
216
+ }
217
+ if (force)
218
+ this.loadingCount = 0;
219
+ // Hide the loading
220
+ if (this.loadingCount === 0) {
221
+ this.lastLoading.dismiss();
222
+ this.lastLoading = undefined;
223
+ }
214
224
  }
215
225
  }
216
226
  /**
@@ -201,13 +201,23 @@ export class NotificationContainer {
201
201
  * @param force Force to hide, otherwise, only the last one
202
202
  */
203
203
  hideLoading(force) {
204
- // Deduct to count
205
- this.loadingCount--;
206
- if (force)
204
+ if (this.lastLoading == null) {
205
+ // Reset count when no loading
207
206
  this.loadingCount = 0;
208
- if (this.loadingCount === 0) {
209
- this.lastLoading?.dismiss();
210
- this.lastLoading = undefined;
207
+ }
208
+ else {
209
+ // Deduct to count
210
+ // Avoid negative result (-1)
211
+ if (this.loadingCount > 0) {
212
+ this.loadingCount--;
213
+ }
214
+ if (force)
215
+ this.loadingCount = 0;
216
+ // Hide the loading
217
+ if (this.loadingCount === 0) {
218
+ this.lastLoading.dismiss();
219
+ this.lastLoading = undefined;
220
+ }
211
221
  }
212
222
  }
213
223
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/notificationbase",
3
- "version": "1.1.46",
3
+ "version": "1.1.48",
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,18 +52,18 @@
52
52
  },
53
53
  "homepage": "https://github.com/ETSOO/NotificationBase#readme",
54
54
  "dependencies": {
55
- "@etsoo/shared": "^1.2.44"
55
+ "@etsoo/shared": "^1.2.46"
56
56
  },
57
57
  "devDependencies": {
58
- "@babel/core": "^7.25.2",
59
- "@babel/plugin-transform-runtime": "^7.24.7",
60
- "@babel/preset-env": "^7.25.3",
61
- "@babel/runtime-corejs3": "^7.25.0",
62
- "@types/jest": "^29.5.12",
58
+ "@babel/core": "^7.25.7",
59
+ "@babel/plugin-transform-runtime": "^7.25.7",
60
+ "@babel/preset-env": "^7.25.7",
61
+ "@babel/runtime-corejs3": "^7.25.7",
62
+ "@types/jest": "^29.5.13",
63
63
  "babel-jest": "^29.7.0",
64
64
  "jest": "^29.7.0",
65
65
  "jest-environment-jsdom": "^29.7.0",
66
- "ts-jest": "^29.2.4",
67
- "typescript": "^5.5.4"
66
+ "ts-jest": "^29.2.5",
67
+ "typescript": "^5.6.2"
68
68
  }
69
69
  }
@@ -456,14 +456,23 @@ export abstract class NotificationContainer<UI, C extends NotificationCallProps>
456
456
  * @param force Force to hide, otherwise, only the last one
457
457
  */
458
458
  hideLoading(force?: boolean) {
459
- // Deduct to count
460
- this.loadingCount--;
459
+ if (this.lastLoading == null) {
460
+ // Reset count when no loading
461
+ this.loadingCount = 0;
462
+ } else {
463
+ // Deduct to count
464
+ // Avoid negative result (-1)
465
+ if (this.loadingCount > 0) {
466
+ this.loadingCount--;
467
+ }
461
468
 
462
- if (force) this.loadingCount = 0;
469
+ if (force) this.loadingCount = 0;
463
470
 
464
- if (this.loadingCount === 0) {
465
- this.lastLoading?.dismiss();
466
- this.lastLoading = undefined;
471
+ // Hide the loading
472
+ if (this.loadingCount === 0) {
473
+ this.lastLoading.dismiss();
474
+ this.lastLoading = undefined;
475
+ }
467
476
  }
468
477
  }
469
478