@streamlayer/feature-gamification 0.15.1 → 0.16.0
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.
- package/lib/gamification.d.ts +1 -1
- package/lib/gamification.js +15 -16
- package/lib/highlights.js +12 -11
- package/package.json +6 -6
package/lib/gamification.d.ts
CHANGED
|
@@ -31,7 +31,7 @@ export declare enum OnboardingStatus {
|
|
|
31
31
|
*/
|
|
32
32
|
export declare class Gamification extends AbstractFeature<'games', PlainMessage<GamesOverlaySettings>> {
|
|
33
33
|
/** user statistics (leaderboard panel) */
|
|
34
|
-
userSummary
|
|
34
|
+
userSummary: ApiStore<GetApiResponseType<typeof queries.$userSummary>>;
|
|
35
35
|
/** questions list (pick history) */
|
|
36
36
|
questions?: ApiStore<GetApiResponseType<typeof queries.$pickHistory>>;
|
|
37
37
|
/** pinned leaderboard id */
|
package/lib/gamification.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AbstractFeature, ApiStore, FeatureStatus, SingleStore, createSingleStore, createComputedStore, } from '@streamlayer/sdk-web-interfaces';
|
|
2
|
-
import { QuestionStatus, QuestionType, FeatureType, } from '@streamlayer/sdk-web-types';
|
|
2
|
+
import { QuestionStatus, QuestionType, FeatureType, SilenceSetting, } from '@streamlayer/sdk-web-types';
|
|
3
3
|
import { NotificationType } from '@streamlayer/sdk-web-notifications';
|
|
4
4
|
import '@streamlayer/sdk-web-core/store';
|
|
5
5
|
import * as queries from './queries';
|
|
@@ -57,6 +57,7 @@ export class Gamification extends AbstractFeature {
|
|
|
57
57
|
super(config, source);
|
|
58
58
|
this.background = gamificationBackground(instance);
|
|
59
59
|
this.storage = new GamificationStorage();
|
|
60
|
+
this.userSummary = new ApiStore(queries.$userSummary(this.background.slStreamId, this.background.userId, instance.transport), 'gamification:userSummary');
|
|
60
61
|
this.leaderboardId = new SingleStore(createSingleStore(this.settings.getValue('pinnedLeaderboardId')), 'pinnedLeaderboardId').getStore();
|
|
61
62
|
this.onboardingStatus = new SingleStore(createSingleStore(OnboardingStatus.Unset), 'onboardingStatus').getStore();
|
|
62
63
|
this.notifications = instance.notifications;
|
|
@@ -90,20 +91,23 @@ export class Gamification extends AbstractFeature {
|
|
|
90
91
|
});
|
|
91
92
|
this.background.activeQuestionId.listen((question) => {
|
|
92
93
|
if (question && question.data && this.onboardingStatus.get()) {
|
|
93
|
-
if (
|
|
94
|
+
if (question.data.question?.id !== undefined &&
|
|
95
|
+
question.data.question.notification !== undefined &&
|
|
96
|
+
question.data.moderation?.bypassNotifications?.inAppSilence !== SilenceSetting.ON &&
|
|
97
|
+
GamificationQuestionTypes.has(question.data.question.type) &&
|
|
94
98
|
question.data.question.status === QuestionStatus.ACTIVE) {
|
|
95
99
|
this.notifications.add({
|
|
96
100
|
type: NotificationType.QUESTION,
|
|
97
|
-
action: () => this.openQuestion(question.data.question.id),
|
|
98
|
-
close: () => this.closeQuestion(question.data.question.id),
|
|
99
|
-
autoHideDuration:
|
|
101
|
+
action: () => question.data?.question && this.openQuestion(question.data.question.id),
|
|
102
|
+
close: () => question.data?.question && this.closeQuestion(question.data.question.id),
|
|
103
|
+
autoHideDuration: +(question.data.moderation?.question?.appearance?.autoHideInterval || '1000'),
|
|
100
104
|
id: this.background.getCurrentSessionId({ prefix: 'notification', entity: question.data.question.id }),
|
|
101
105
|
data: {
|
|
102
|
-
title: question.data.notification.title,
|
|
103
|
-
color: question.data.notification.indicatorColor,
|
|
104
|
-
icon: question.data.notification.image,
|
|
105
|
-
imageMode: question.data.notification.imageMode,
|
|
106
|
-
imagePosition: question.data.notification.imagePosition,
|
|
106
|
+
title: question.data.question.notification.title,
|
|
107
|
+
color: question.data.question.notification.indicatorColor,
|
|
108
|
+
icon: question.data.question.notification.image,
|
|
109
|
+
imageMode: question.data.question.notification.imageMode,
|
|
110
|
+
imagePosition: question.data.question.notification.imagePosition,
|
|
107
111
|
},
|
|
108
112
|
});
|
|
109
113
|
}
|
|
@@ -185,12 +189,7 @@ export class Gamification extends AbstractFeature {
|
|
|
185
189
|
});
|
|
186
190
|
};
|
|
187
191
|
connect = (transport) => {
|
|
188
|
-
|
|
189
|
-
this.userSummary = new ApiStore(queries.$userSummary(this.background.slStreamId, this.background.userId, transport), 'gamification:userSummary');
|
|
190
|
-
}
|
|
191
|
-
else {
|
|
192
|
-
this.userSummary.invalidate();
|
|
193
|
-
}
|
|
192
|
+
this.userSummary.invalidate();
|
|
194
193
|
this.leaderboardList = new ApiStore(queries.$leaderboardList(this.background.slStreamId, this.leaderboardId, transport), 'gamification:leaderboardList');
|
|
195
194
|
if (!this.questions) {
|
|
196
195
|
this.questions = new ApiStore(queries.$pickHistory(this.background.slStreamId, transport), 'gamification:questions');
|
package/lib/highlights.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AbstractFeature, ApiStore, FeatureStatus, createComputedStore, } from '@streamlayer/sdk-web-interfaces';
|
|
2
|
-
import { QuestionStatus, QuestionType, FeatureType } from '@streamlayer/sdk-web-types';
|
|
2
|
+
import { QuestionStatus, QuestionType, FeatureType, SilenceSetting } from '@streamlayer/sdk-web-types';
|
|
3
3
|
import { NotificationType } from '@streamlayer/sdk-web-notifications';
|
|
4
4
|
import '@streamlayer/sdk-web-core/store';
|
|
5
5
|
import * as queries from './queries';
|
|
@@ -28,22 +28,23 @@ export class Highlights extends AbstractFeature {
|
|
|
28
28
|
}
|
|
29
29
|
});
|
|
30
30
|
this.background.activeQuestionId.listen((question) => {
|
|
31
|
-
if (question &&
|
|
32
|
-
question
|
|
31
|
+
if (question?.data?.question?.id &&
|
|
32
|
+
question?.data?.question?.notification &&
|
|
33
|
+
question.data.moderation?.bypassNotifications?.inAppSilence !== SilenceSetting.ON &&
|
|
33
34
|
question.data.question.type === QuestionType.FACTOID &&
|
|
34
35
|
question.data.question.status === QuestionStatus.ACTIVE) {
|
|
35
36
|
this.notifications.add({
|
|
36
37
|
type: NotificationType.QUESTION,
|
|
37
|
-
action: () => this.openHighlight(question.data.question.id),
|
|
38
|
-
close: () => this.closeHighlight(question.data.question.id),
|
|
39
|
-
autoHideDuration:
|
|
38
|
+
action: () => question.data?.question && this.openHighlight(question.data.question.id),
|
|
39
|
+
close: () => question.data?.question && this.closeHighlight(question.data.question.id),
|
|
40
|
+
autoHideDuration: +(question.data.moderation?.question?.appearance?.autoHideInterval || '1000'),
|
|
40
41
|
id: this.background.getCurrentSessionId({ prefix: 'notification', entity: question.data.question.id }),
|
|
41
42
|
data: {
|
|
42
|
-
title: question.data.notification.title,
|
|
43
|
-
color: question.data.notification.indicatorColor,
|
|
44
|
-
icon: question.data.notification.image,
|
|
45
|
-
imageMode: question.data.notification.imageMode,
|
|
46
|
-
imagePosition: question.data.notification.imagePosition,
|
|
43
|
+
title: question.data.question.notification.title,
|
|
44
|
+
color: question.data.question.notification.indicatorColor,
|
|
45
|
+
icon: question.data.question.notification.image,
|
|
46
|
+
imageMode: question.data.question.notification.imageMode,
|
|
47
|
+
imagePosition: question.data.question.notification.imagePosition,
|
|
47
48
|
},
|
|
48
49
|
});
|
|
49
50
|
}
|
package/package.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@streamlayer/feature-gamification",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.0",
|
|
4
4
|
"peerDependencies": {
|
|
5
5
|
"@bufbuild/protobuf": "^1.4.2",
|
|
6
6
|
"@streamlayer/sl-eslib": "^5.45.1",
|
|
7
7
|
"nanostores": "^0.9.4",
|
|
8
|
-
"@streamlayer/sdk-web-interfaces": "^0.
|
|
9
|
-
"@streamlayer/sdk-web-core": "^0.
|
|
10
|
-
"@streamlayer/sdk-web-api": "^0.0.
|
|
11
|
-
"@streamlayer/sdk-web-types": "^0.
|
|
8
|
+
"@streamlayer/sdk-web-interfaces": "^0.18.0",
|
|
9
|
+
"@streamlayer/sdk-web-core": "^0.12.0",
|
|
10
|
+
"@streamlayer/sdk-web-api": "^0.0.2",
|
|
11
|
+
"@streamlayer/sdk-web-types": "^0.16.0",
|
|
12
12
|
"@streamlayer/sdk-web-storage": "^0.3.2",
|
|
13
13
|
"@streamlayer/sdk-web-logger": "^0.5.2",
|
|
14
|
-
"@streamlayer/sdk-web-notifications": "^0.9.
|
|
14
|
+
"@streamlayer/sdk-web-notifications": "^0.9.4"
|
|
15
15
|
},
|
|
16
16
|
"devDependencies": {
|
|
17
17
|
"tslib": "^2.6.2"
|