@streamlayer/sdk-web-notifications 0.0.6 → 0.0.7

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.
@@ -40,6 +40,7 @@ export type Notification<M extends Record<string, Function> = never> = {
40
40
  methods?: M;
41
41
  data: NotificationData;
42
42
  id: string;
43
+ persistent?: boolean;
43
44
  };
44
45
  /**
45
46
  * @description app notifications (inapp)
@@ -49,7 +50,7 @@ export declare class Notifications {
49
50
  private storage;
50
51
  constructor(options?: Partial<NotificationsQueueOptions>);
51
52
  add: (notification: Notification) => void;
52
- close: (notificationId: string) => void;
53
+ close: (notificationId: string, markAsViewed?: boolean) => void;
53
54
  getQueueStore: () => import("nanostores").WritableAtom<Map<string, Notification> | undefined>;
54
55
  markAsViewed: (notificationId: string) => void;
55
56
  }
@@ -22,9 +22,11 @@ export class Notifications {
22
22
  this.queue.addToQueue(notification);
23
23
  }
24
24
  };
25
- close = (notificationId) => {
25
+ close = (notificationId, markAsViewed = true) => {
26
26
  this.queue.closeNotification(notificationId);
27
- this.markAsViewed(notificationId);
27
+ if (markAsViewed) {
28
+ this.markAsViewed(notificationId);
29
+ }
28
30
  };
29
31
  getQueueStore = () => {
30
32
  return this.queue.notificationsList;
@@ -48,7 +48,17 @@ export class NotificationsQueue {
48
48
  */
49
49
  if (this.activeQueue.size === this.options.concurrency) {
50
50
  const [job] = this.activeQueue;
51
- this.closeNotification(job);
51
+ const notification = this.store.get(job);
52
+ if (notification?.persistent !== true) {
53
+ this.closeNotification(job);
54
+ }
55
+ else {
56
+ const [job] = this.waitingQueue;
57
+ if (this.waitingQueue.size > 1) {
58
+ this.closeNotification(job);
59
+ }
60
+ this.tickWaitingQueue();
61
+ }
52
62
  }
53
63
  else {
54
64
  this.tickWaitingQueue();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@streamlayer/sdk-web-notifications",
3
- "version": "0.0.6",
3
+ "version": "0.0.7",
4
4
  "type": "module",
5
5
  "main": "./lib/index.js",
6
6
  "typings": "./lib/index.d.ts",
@@ -9,10 +9,10 @@
9
9
  "package.json"
10
10
  ],
11
11
  "peerDependencies": {
12
- "@streamlayer/sdk-web-interfaces": "^0.18.21",
13
- "@streamlayer/sdk-web-types": "^0.1.0",
14
- "@streamlayer/sdk-web-logger": "^0.0.1",
15
- "@streamlayer/sdk-web-storage": "^0.0.4"
12
+ "@streamlayer/sdk-web-interfaces": "^0.1.0",
13
+ "@streamlayer/sdk-web-logger": "^0.1.0",
14
+ "@streamlayer/sdk-web-storage": "^0.1.0",
15
+ "@streamlayer/sdk-web-types": "^0.1.0"
16
16
  },
17
17
  "exports": {
18
18
  ".": {
@@ -22,10 +22,10 @@
22
22
  }
23
23
  },
24
24
  "devDependencies": {
25
+ "@nx/playwright": "^17.2.8",
26
+ "@nx/webpack": "^17.2.8",
27
+ "@playwright/test": "^1.41.1",
25
28
  "tslib": "^2.6.2",
26
- "@nx/playwright": "17.1.1",
27
- "@playwright/test": "^1.39.0",
28
- "@nx/webpack": "17.0.3",
29
29
  "webpack": "^5.89.0"
30
30
  }
31
31
  }