@streamlayer/feature-gamification 0.25.0 → 0.26.1

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.
@@ -36,6 +36,8 @@ export declare class Gamification extends AbstractFeature<'games', PlainMessage<
36
36
  };
37
37
  /** opened question */
38
38
  openedQuestion: GamificationBackground['openedQuestion'];
39
+ /** current user id */
40
+ currentUserId: GamificationBackground['userId'];
39
41
  /** pinned leaderboard id */
40
42
  openedUser: WritableAtom<LeaderboardItem | undefined>;
41
43
  closeFeature: () => void;
@@ -33,6 +33,8 @@ export class Gamification extends AbstractFeature {
33
33
  onboardingStatus;
34
34
  /** opened question */
35
35
  openedQuestion;
36
+ /** current user id */
37
+ currentUserId;
36
38
  /** pinned leaderboard id */
37
39
  openedUser;
38
40
  closeFeature;
@@ -49,6 +51,7 @@ export class Gamification extends AbstractFeature {
49
51
  this.storage = new GamificationStorage();
50
52
  this.userSummary = new ApiStore(queries.$userSummary(this.background.slStreamId, this.background.userId, instance.transport), 'gamification:userSummary');
51
53
  this.feedList = this.background.feedList;
54
+ this.currentUserId = this.background.userId;
52
55
  this.openedUser = createSingleStore(undefined);
53
56
  this.leaderboardId = new SingleStore(createSingleStore(this.settings.getValue('pinnedLeaderboardId')), 'pinnedLeaderboardId').getStore();
54
57
  this.onboardingStatus = onboarding(this, this.background, instance.transport, instance.notifications);
@@ -119,6 +122,33 @@ export class Gamification extends AbstractFeature {
119
122
  },
120
123
  });
121
124
  }
125
+ else if (question.data.question.type === QuestionType.TWEET) {
126
+ const optionsValue = question.data.question.options?.options.value;
127
+ const tweetView = {
128
+ title: question.data.question.notification.title,
129
+ body: question.data.question.notification.body,
130
+ image: question.data.question.notification.image,
131
+ account: {
132
+ // ToDo: add later
133
+ image: '',
134
+ name: optionsValue?.tweetMeta?.account || '',
135
+ // ToDo: add later
136
+ userName: '',
137
+ verified: !!optionsValue?.tweetMeta?.accountVerified,
138
+ },
139
+ };
140
+ this.notifications.add({
141
+ type: NotificationType.QUESTION,
142
+ action: () => question.data?.question && this.openQuestion(question.data.question.id),
143
+ close: () => question.data?.question && this.closeQuestion(question.data.question.id),
144
+ autoHideDuration: 1000 * +(question.data.question?.appearance?.autoHideInterval || '5'),
145
+ id: this.background.getCurrentSessionId({ prefix: 'notification', entity: question.data.question.id }),
146
+ data: {
147
+ questionType: question.data.question.type,
148
+ tweet: tweetView,
149
+ },
150
+ });
151
+ }
122
152
  }
123
153
  }
124
154
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@streamlayer/feature-gamification",
3
- "version": "0.25.0",
3
+ "version": "0.26.1",
4
4
  "peerDependencies": {
5
5
  "@bufbuild/protobuf": "^1.4.2",
6
6
  "@streamlayer/sl-eslib": "^5.53.6",
@@ -10,7 +10,7 @@
10
10
  "@streamlayer/sdk-web-core": "^0.17.8",
11
11
  "@streamlayer/sdk-web-interfaces": "^0.18.15",
12
12
  "@streamlayer/sdk-web-logger": "^0.0.4",
13
- "@streamlayer/sdk-web-notifications": "^0.12.1",
13
+ "@streamlayer/sdk-web-notifications": "^0.13.0",
14
14
  "@streamlayer/sdk-web-storage": "^0.0.4",
15
15
  "@streamlayer/sdk-web-types": "^0.20.1"
16
16
  },