Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/telegram-dev-03' into telegram-d…
Browse files Browse the repository at this point in the history
…ev-03
  • Loading branch information
saltict committed Aug 16, 2024
2 parents 7cf5dbd + 282651c commit 3185fd4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ const Component = ({ className, defaultSelectedTab, gameId, tabGroupItems }: Pro
})();

const currentTabInfo = useMemo(() => {
setLeaderboardItems([]);

return tabGroupItems.find((i) => i.value === selectedTab);
}, [selectedTab, tabGroupItems]);

Expand All @@ -87,10 +89,10 @@ const Component = ({ className, defaultSelectedTab, gameId, tabGroupItems }: Pro
}, [defaultSelectedTab]);

useEffect(() => {
let leaderboardSub: { unsubscribe: () => void } | null = null;

if (currentTabInfo) {
leaderboardSub = apiSDK.subscribeLeaderboard(currentTabInfo.leaderboardInfo.id, currentTabInfo.leaderboardInfo.context).subscribe((data) => {
const subscribeLeaderboard = async () => {
if (currentTabInfo) {
const data = await apiSDK.fetchLeaderboard(currentTabInfo.leaderboardInfo.id, currentTabInfo.leaderboardInfo.context) as LeaderboardPerson[];
setLeaderboardItems(data);

// Find mine
Expand All @@ -99,15 +101,13 @@ const Component = ({ className, defaultSelectedTab, gameId, tabGroupItems }: Pro
if (mine) {
setMine(mine);
}
});
}

return () => {
if (leaderboardSub) {
leaderboardSub.unsubscribe();
}
};
}, [currentTabInfo, gameId]);

subscribeLeaderboard();

return () => {};
}, [currentTabInfo]);

return <div className={className}>
{
Expand Down
1 change: 1 addition & 0 deletions packages/extension-koni-ui/src/connector/booka/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,7 @@ export class BookaSdk {
if (leaderBoard) {
this.leaderBoardSubject.next(leaderBoard);
}
return leaderBoard;
}

subscribeLeaderboard (id: number, context: Record<string, unknown> = {}) {
Expand Down

0 comments on commit 3185fd4

Please sign in to comment.