Skip to content

Commit

Permalink
fix: fixed wrong ranking position
Browse files Browse the repository at this point in the history
  • Loading branch information
mxgic1337 committed Dec 3, 2024
1 parent fdb0221 commit ebaa410
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "faceit-stats-widget",
"private": true,
"version": "2.1.0",
"version": "2.1.1",
"type": "module",
"scripts": {
"dev": "vite",
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Widget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ export const Widget = ({
}
getStats(true)
const interval =
setInterval(getStats, 1000 * 60)
setInterval(getStats, 1000 * 30)
document.getElementsByTagName("html")[0].classList.add(`${theme}-theme`)

return () => {
Expand Down
4 changes: 3 additions & 1 deletion src/utils/faceit_util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ interface V4StatsResponse {
/** Topka graczy zwracane przez API v4 */
interface V4RankingResponse {
items: {
player_id: string,
position: number,
}[]
}
Expand Down Expand Up @@ -124,7 +125,8 @@ export function getPlayerStats(id: string, startDate: Date): Promise<FaceitPlaye
}).then(async response => {
if (!response.ok) { console.error(await response.text()); resolve(undefined); return }
const v4RankingResponse = (await response.json() as V4RankingResponse);
const ranking = v4RankingResponse.items[0] ? v4RankingResponse.items[0].position : undefined;
const rankingItem = v4RankingResponse.items.find(item => item.player_id === v4PlayersResponse.player_id);
const ranking = rankingItem ? rankingItem.position : undefined;

resolve({
id: v4PlayersResponse.player_id,
Expand Down

0 comments on commit ebaa410

Please sign in to comment.