@streamlayer/sdk-web-notifications 1.3.27 → 1.3.29

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.
@@ -1,4 +1,4 @@
1
- import { InstantView, QuestionType, GameSettings, TweetHistory, ExtendedQuestion, NotificationType } from '@streamlayer/sdk-web-types';
1
+ import { InstantView, QuestionType, GameSettings, TweetHistory, ExtendedQuestion, NotificationType, AdUnit } from '@streamlayer/sdk-web-types';
2
2
  import { NotificationsQueue, NotificationsQueueOptions } from './queue';
3
3
  export type NotificationData = {
4
4
  questionId: string;
@@ -19,10 +19,14 @@ export type NotificationData = {
19
19
  appearance: ExtendedQuestion['appearance'];
20
20
  sponsorship: ExtendedQuestion['sponsorship'];
21
21
  notification: ExtendedQuestion['notification'];
22
+ adUnit?: AdUnit;
23
+ sponsorLogo?: string;
24
+ isVideo?: boolean;
22
25
  };
23
26
  insight?: InstantView;
24
27
  onboarding?: GameSettings & {
25
28
  instantOpen?: boolean;
29
+ markIstantOpen?: () => void;
26
30
  };
27
31
  tweet?: {
28
32
  title: string;
@@ -65,6 +69,7 @@ export declare class Notifications {
65
69
  isViewed: (notificationId: string) => string | undefined;
66
70
  add: (notification: Notification) => void;
67
71
  close: (notificationId: string, { markAsViewed, animateHiding }?: NotificationCloseOptions) => void;
72
+ update: (notificationId: string, updateFn: (notification: Notification | undefined) => void) => void;
68
73
  getActiveNotification: () => Notification | null;
69
74
  getQueueStore: () => import("nanostores").WritableAtom<Map<string, Notification> | undefined>;
70
75
  markAsViewed: (notificationId: string) => void;
@@ -42,6 +42,10 @@ export class Notifications {
42
42
  this.markAsViewed(notificationId);
43
43
  }
44
44
  };
45
+ update = (notificationId, updateFn) => {
46
+ const notification = this.queue.notificationsList.get()?.get(notificationId);
47
+ updateFn(notification);
48
+ };
45
49
  getActiveNotification = () => {
46
50
  const notifications = this.queue.notificationsList.get();
47
51
  if (!notifications?.size) {
@@ -116,12 +116,13 @@ export class NotificationsQueue {
116
116
  if (notification) {
117
117
  // do not hide notification if we have more than one notification in waiting queue,
118
118
  // because we need to show next notification immediately
119
- notification.hiding = !(this.waitingQueue.size >= this.options.concurrency) && animateHiding;
119
+ const shouldAnimate = !(this.waitingQueue.size >= this.options.concurrency) && animateHiding;
120
+ notification.hiding = shouldAnimate;
120
121
  this.notificationsList.set(prevQueue);
121
- const timeout = setTimeout(() => {
122
- const prevQueue = new Map(this.notificationsList.get());
123
- prevQueue.delete(notificationId);
124
- this.notificationsList.set(prevQueue);
122
+ const finalize = () => {
123
+ const nextQueue = new Map(this.notificationsList.get());
124
+ nextQueue.delete(notificationId);
125
+ this.notificationsList.set(nextQueue);
125
126
  const timeout = this.timeouts.get(notificationId);
126
127
  if (timeout !== undefined) {
127
128
  clearTimeout(timeout);
@@ -138,8 +139,14 @@ export class NotificationsQueue {
138
139
  },
139
140
  });
140
141
  }
141
- }, this.options.animationDelay || 0);
142
- this.timeouts.set(notificationId, timeout);
142
+ };
143
+ if (shouldAnimate) {
144
+ const timeout = setTimeout(finalize, this.options.animationDelay || 0);
145
+ this.timeouts.set(notificationId, timeout);
146
+ }
147
+ else {
148
+ finalize();
149
+ }
143
150
  }
144
151
  this.store.delete(notificationId);
145
152
  this.activeQueue.delete(notificationId);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@streamlayer/sdk-web-notifications",
3
- "version": "1.3.27",
3
+ "version": "1.3.29",
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": "^1.6.3",
13
- "@streamlayer/sdk-web-logger": "^1.0.65",
14
- "@streamlayer/sdk-web-storage": "^1.0.65",
15
- "@streamlayer/sdk-web-types": "^1.13.0"
12
+ "@streamlayer/sdk-web-interfaces": "^1.7.0",
13
+ "@streamlayer/sdk-web-logger": "^1.0.67",
14
+ "@streamlayer/sdk-web-storage": "^1.0.67",
15
+ "@streamlayer/sdk-web-types": "^1.14.0"
16
16
  },
17
17
  "exports": {
18
18
  ".": {