@playbasis-ai/qwikcard-sdk 2.3.22 → 2.3.24
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/CHANGELOG.md +12 -0
- package/dist/QwikCardApp.d.ts.map +1 -1
- package/dist/QwikCardApp.js +38 -8
- package/dist/api/client.d.ts.map +1 -1
- package/dist/api/client.js +1 -1
- package/dist/web/widgetAssets.d.ts +1 -1
- package/dist/web/widgetAssets.d.ts.map +1 -1
- package/dist/web/widgetAssets.js +1 -1
- package/package.json +1 -1
- package/src/QwikCardApp.tsx +41 -12
- package/src/api/client.ts +4 -2
- package/src/web/widgetAssets.ts +1 -1
package/package.json
CHANGED
package/src/QwikCardApp.tsx
CHANGED
|
@@ -67,18 +67,50 @@ function AppContent({ leaderboardId }: { leaderboardId?: string }) {
|
|
|
67
67
|
? await (async () => {
|
|
68
68
|
try {
|
|
69
69
|
const res = await client.getLeaderboard(leaderboardId, { limit: 50 });
|
|
70
|
-
|
|
71
|
-
userId:
|
|
72
|
-
rank:
|
|
73
|
-
displayName:
|
|
74
|
-
score:
|
|
75
|
-
isCurrentUser:
|
|
70
|
+
const normalized = res.entries.map((entry) => ({
|
|
71
|
+
userId: entry.playerId,
|
|
72
|
+
rank: entry.rank,
|
|
73
|
+
displayName: entry.displayName || 'Player',
|
|
74
|
+
score: entry.score,
|
|
75
|
+
isCurrentUser: entry.playerId === player.id,
|
|
76
76
|
}));
|
|
77
|
+
const hasCurrentUser = normalized.some((entry) => entry.isCurrentUser);
|
|
78
|
+
|
|
79
|
+
if (!hasCurrentUser) {
|
|
80
|
+
return [
|
|
81
|
+
{
|
|
82
|
+
userId: player.id,
|
|
83
|
+
rank: 0,
|
|
84
|
+
displayName: player.displayName || 'You',
|
|
85
|
+
score: xp,
|
|
86
|
+
isCurrentUser: true,
|
|
87
|
+
},
|
|
88
|
+
...normalized,
|
|
89
|
+
];
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return normalized;
|
|
77
93
|
} catch {
|
|
78
|
-
return [
|
|
94
|
+
return [
|
|
95
|
+
{
|
|
96
|
+
userId: player.id,
|
|
97
|
+
rank: 0,
|
|
98
|
+
displayName: player.displayName || 'You',
|
|
99
|
+
score: xp,
|
|
100
|
+
isCurrentUser: true,
|
|
101
|
+
},
|
|
102
|
+
];
|
|
79
103
|
}
|
|
80
104
|
})()
|
|
81
|
-
: [
|
|
105
|
+
: [
|
|
106
|
+
{
|
|
107
|
+
userId: player.id,
|
|
108
|
+
rank: 0,
|
|
109
|
+
displayName: player.displayName || 'You',
|
|
110
|
+
score: xp,
|
|
111
|
+
isCurrentUser: true,
|
|
112
|
+
},
|
|
113
|
+
];
|
|
82
114
|
|
|
83
115
|
return {
|
|
84
116
|
user: {
|
|
@@ -280,10 +312,7 @@ function AppContent({ leaderboardId }: { leaderboardId?: string }) {
|
|
|
280
312
|
{activeGame && (
|
|
281
313
|
<View style={{ flex: 1 }}>
|
|
282
314
|
<View style={gameHeaderStyle}>
|
|
283
|
-
<TouchableOpacity
|
|
284
|
-
onPress={closeGame}
|
|
285
|
-
style={{ paddingVertical: 4, paddingRight: 8 }}
|
|
286
|
-
>
|
|
315
|
+
<TouchableOpacity onPress={closeGame} style={{ paddingVertical: 4, paddingRight: 8 }}>
|
|
287
316
|
<Text style={{ color: theme.colors.primary, fontWeight: '700' }}>← Arcade</Text>
|
|
288
317
|
</TouchableOpacity>
|
|
289
318
|
<Text
|
package/src/api/client.ts
CHANGED
|
@@ -316,7 +316,9 @@ export class PlaybasisClient {
|
|
|
316
316
|
| { items?: LeaderboardEntry[]; total?: number }
|
|
317
317
|
| { leaderboard?: { entries?: LeaderboardEntry[]; total?: number } }
|
|
318
318
|
>('GET', `/leaderboards/${encodeURIComponent(leaderboardId)}?${params}`);
|
|
319
|
-
const leaderboardData = data as {
|
|
319
|
+
const leaderboardData = data as {
|
|
320
|
+
leaderboard?: { entries?: LeaderboardEntry[]; total?: number };
|
|
321
|
+
};
|
|
320
322
|
const entries =
|
|
321
323
|
'entries' in data
|
|
322
324
|
? data.entries
|
|
@@ -326,7 +328,7 @@ export class PlaybasisClient {
|
|
|
326
328
|
const total =
|
|
327
329
|
'total' in data && typeof data.total === 'number'
|
|
328
330
|
? data.total
|
|
329
|
-
: leaderboardData.leaderboard?.total ?? entries?.length ?? 0;
|
|
331
|
+
: (leaderboardData.leaderboard?.total ?? entries?.length ?? 0);
|
|
330
332
|
|
|
331
333
|
const normalizedEntries = (entries || []).map((entry, index) => {
|
|
332
334
|
const raw = entry as LeaderboardEntry & {
|