@streamlayer/feature-gamification 0.35.1 → 0.37.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/background.js +4 -6
- package/lib/deepLink.d.ts +1 -1
- package/lib/deepLink.js +20 -6
- package/lib/gamification.js +3 -1
- package/lib/queries/deepLink.d.ts +2 -1
- package/lib/queries/deepLink.js +4 -2
- package/package.json +9 -9
package/lib/background.js
CHANGED
|
@@ -75,12 +75,10 @@ export class GamificationBackground {
|
|
|
75
75
|
});
|
|
76
76
|
this.feedSubscription = queries.feedSubscription(this.slStreamId, instance.transport);
|
|
77
77
|
this.feedSubscription.addListener('feed-subscription-active-question', (response) => {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}
|
|
83
|
-
});
|
|
78
|
+
const $activeQuestionId = this.activeQuestionId.getStore();
|
|
79
|
+
if ($activeQuestionId) {
|
|
80
|
+
$activeQuestionId.mutate(response.data?.attributes);
|
|
81
|
+
}
|
|
84
82
|
});
|
|
85
83
|
// refresh moderation if question empty, it`s mean that moderation was changed
|
|
86
84
|
this.feedSubscription.addListener('moderation update', (response) => {
|
package/lib/deepLink.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ type DeepLinkData = {
|
|
|
5
5
|
loading?: boolean;
|
|
6
6
|
error?: string;
|
|
7
7
|
};
|
|
8
|
-
export declare const deepLink: (transport: Transport, $eventId: ReadableAtom<string | undefined>, $userId: ReadableAtom<string | undefined>) => {
|
|
8
|
+
export declare const deepLink: (transport: Transport, $eventId: ReadableAtom<string | undefined>, $externalEventId: ReadableAtom<string | undefined>, $userId: ReadableAtom<string | undefined>) => {
|
|
9
9
|
$store: import("nanostores").MapStore<DeepLinkData>;
|
|
10
10
|
fetch: typeof fetch;
|
|
11
11
|
};
|
package/lib/deepLink.js
CHANGED
|
@@ -1,23 +1,37 @@
|
|
|
1
1
|
import { createMapStore } from '@streamlayer/sdk-web-interfaces';
|
|
2
|
+
import { DEEP_LINK_USER_ID, DEEP_LINK_EVENT_ID, DEEP_LINK_EXTERNAL_EVENT_ID, } from '@streamlayer/sdk-web-core';
|
|
2
3
|
import { onMount } from 'nanostores';
|
|
3
4
|
import { $deepLink, generateShortLink } from './queries/deepLink';
|
|
4
|
-
|
|
5
|
+
const createUrlParams = (prevParams, data) => {
|
|
6
|
+
const url = new URLSearchParams(prevParams);
|
|
7
|
+
for (const [key, value] of Object.entries(data)) {
|
|
8
|
+
url.append(key, value);
|
|
9
|
+
}
|
|
10
|
+
return url.toString();
|
|
11
|
+
};
|
|
12
|
+
export const deepLink = (transport, $eventId, $externalEventId, $userId) => {
|
|
5
13
|
const $store = createMapStore({});
|
|
6
14
|
onMount($store, () => {
|
|
7
|
-
const $branchLink = $deepLink(transport, [$eventId]);
|
|
15
|
+
const $branchLink = $deepLink(transport, [$eventId, $externalEventId]);
|
|
8
16
|
const cancel = $branchLink.subscribe(async ({ data, error, loading }) => {
|
|
9
17
|
const mobileDeepLink = error ? 'https://masters.com' : data?.url;
|
|
18
|
+
const userId = $userId.get() || '';
|
|
19
|
+
const eventId = $eventId.get() || '';
|
|
20
|
+
const externalEventId = $externalEventId.get() || '';
|
|
21
|
+
const urlParamsData = {
|
|
22
|
+
[DEEP_LINK_USER_ID]: userId,
|
|
23
|
+
[DEEP_LINK_EVENT_ID]: eventId,
|
|
24
|
+
[DEEP_LINK_EXTERNAL_EVENT_ID]: externalEventId,
|
|
25
|
+
};
|
|
10
26
|
if (!loading && mobileDeepLink) {
|
|
11
27
|
$store.setKey('loading', true);
|
|
12
28
|
let search = window.location.search;
|
|
13
29
|
let hash = window.location.hash;
|
|
14
30
|
if ((search && hash) || hash) {
|
|
15
|
-
|
|
16
|
-
params.append('slprms', `sl_eid=${$eventId.get()}:sl_uid=${$userId.get()}`);
|
|
17
|
-
search = `?${params.toString()}`;
|
|
31
|
+
search = `?${createUrlParams(search, urlParamsData)}`;
|
|
18
32
|
}
|
|
19
33
|
else {
|
|
20
|
-
hash =
|
|
34
|
+
hash = `#${createUrlParams('', urlParamsData)}`;
|
|
21
35
|
}
|
|
22
36
|
const desktopLink = window.location.origin + window.location.pathname + search + hash;
|
|
23
37
|
const shortLink = await generateShortLink(transport, { web: desktopLink, mobile: mobileDeepLink });
|
package/lib/gamification.js
CHANGED
|
@@ -63,7 +63,7 @@ export class Gamification extends AbstractFeature {
|
|
|
63
63
|
this.closeFeature = () => instance.sdk.closeFeature(true);
|
|
64
64
|
this.openFeature = () => instance.sdk.openFeature(FeatureType.GAMES);
|
|
65
65
|
this.openedQuestion = this.background.openedQuestion;
|
|
66
|
-
this.deepLink = deepLink(this.transport, this.background.slStreamId, this.background.userId);
|
|
66
|
+
this.deepLink = deepLink(this.transport, this.background.slStreamId, instance.stores.providerStreamId.getStore(), this.background.userId);
|
|
67
67
|
this.leaderboardList = leaderboard(this.transport, this.background.slStreamId, this.background.userId, this.friends);
|
|
68
68
|
this.status.subscribe((status) => {
|
|
69
69
|
if (status === FeatureStatus.Ready) {
|
|
@@ -230,6 +230,7 @@ export class Gamification extends AbstractFeature {
|
|
|
230
230
|
const instantView = {
|
|
231
231
|
heading: question.data.question.notification.title,
|
|
232
232
|
body: question.data.question.notification.body,
|
|
233
|
+
imageMode: question.data.question.notification.imageMode,
|
|
233
234
|
image: optionsValue?.image,
|
|
234
235
|
video: {
|
|
235
236
|
id: optionsValue?.video?.id || '',
|
|
@@ -261,6 +262,7 @@ export class Gamification extends AbstractFeature {
|
|
|
261
262
|
image: question.data.question.notification?.image,
|
|
262
263
|
account: optionsValue?.tweetMeta?.account || '',
|
|
263
264
|
accountVerified: !!optionsValue?.tweetMeta?.accountVerified,
|
|
265
|
+
tweet: optionsValue?.tweetMeta?.tweet,
|
|
264
266
|
};
|
|
265
267
|
this.notifications.add({
|
|
266
268
|
type: NotificationType.QUESTION,
|
|
@@ -2,7 +2,8 @@ import type { Transport } from '@streamlayer/sdk-web-api';
|
|
|
2
2
|
import { ReadableAtom } from 'nanostores';
|
|
3
3
|
import { DeepLink } from '@streamlayer/sl-eslib/sdkSettings/client/client_pb';
|
|
4
4
|
type EventId = ReadableAtom<string | undefined>;
|
|
5
|
-
|
|
5
|
+
type ExternalEventId = ReadableAtom<string | undefined>;
|
|
6
|
+
export declare const $deepLink: (transport: Transport, params: [EventId, ExternalEventId]) => import("@nanostores/query").FetcherStore<DeepLink | undefined, any>;
|
|
6
7
|
export declare const generateShortLink: (transport: Transport, { web, mobile }: {
|
|
7
8
|
web: string;
|
|
8
9
|
mobile: string;
|
package/lib/queries/deepLink.js
CHANGED
|
@@ -6,11 +6,13 @@ export const $deepLink = (transport, params) => {
|
|
|
6
6
|
params,
|
|
7
7
|
});
|
|
8
8
|
return transport.nanoquery.createFetcherStore(queryKey, {
|
|
9
|
-
fetcher: async (_, __, eventId) => {
|
|
9
|
+
fetcher: async (_, __, eventId, externalEventId) => {
|
|
10
10
|
if (!eventId) {
|
|
11
11
|
return {};
|
|
12
12
|
}
|
|
13
|
-
const res = await client.generateDeepLink({
|
|
13
|
+
const res = await client.generateDeepLink({
|
|
14
|
+
data: { gamification: true, externalEventId: externalEventId, eventId: eventId },
|
|
15
|
+
});
|
|
14
16
|
return res.data?.attributes;
|
|
15
17
|
},
|
|
16
18
|
});
|
package/package.json
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@streamlayer/feature-gamification",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.37.0",
|
|
4
4
|
"peerDependencies": {
|
|
5
5
|
"@bufbuild/protobuf": "^1.6.0",
|
|
6
6
|
"@fastify/deepmerge": "*",
|
|
7
|
-
"@streamlayer/sl-eslib": "^5.
|
|
7
|
+
"@streamlayer/sl-eslib": "^5.67.0",
|
|
8
8
|
"nanostores": "^0.9.5",
|
|
9
|
-
"@streamlayer/sdk-web-api": "^0.
|
|
10
|
-
"@streamlayer/sdk-web-core": "^0.
|
|
11
|
-
"@streamlayer/sdk-web-interfaces": "^0.20.
|
|
12
|
-
"@streamlayer/sdk-web-logger": "^0.5.
|
|
13
|
-
"@streamlayer/sdk-web-notifications": "^0.13.
|
|
14
|
-
"@streamlayer/sdk-web-storage": "^0.
|
|
15
|
-
"@streamlayer/sdk-web-types": "^0.
|
|
9
|
+
"@streamlayer/sdk-web-api": "^0.21.1",
|
|
10
|
+
"@streamlayer/sdk-web-core": "^0.20.0",
|
|
11
|
+
"@streamlayer/sdk-web-interfaces": "^0.20.3",
|
|
12
|
+
"@streamlayer/sdk-web-logger": "^0.5.14",
|
|
13
|
+
"@streamlayer/sdk-web-notifications": "^0.13.9",
|
|
14
|
+
"@streamlayer/sdk-web-storage": "^0.4.1",
|
|
15
|
+
"@streamlayer/sdk-web-types": "^0.22.1"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
18
|
"tslib": "^2.6.2"
|