mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 19:49:50 +02:00
fix: some rating functionality
This commit is contained in:
1 parent
fcb848df5b
commit
5bf6a14cff
9 files changed
+104
-111
No files matched your search
@@ -1,24 +1,41 @@
|
||||
// import { Region } from '@blitzkit/core';
|
||||
// import { context } from '../blitzkit/context';
|
||||
// import { patientFetch } from '../blitzkit/patientFetch';
|
||||
// import { regionToRegionSubdomain } from './regionToRegionSubdomain';
|
||||
import { RatingLeague, RatingReward, Region } from '@blitzkit/core';
|
||||
import { context } from '../blitzkit/context';
|
||||
import { patientFetch } from '../blitzkit/patientFetch';
|
||||
import { regionToRegionSubdomain } from './regionToRegionSubdomain';
|
||||
|
||||
// const cache: Partial<Record<Region, RatingInfo>> = {};
|
||||
export type RatingInfo =
|
||||
| {
|
||||
detail: undefined;
|
||||
|
||||
// export async function getRatingInfo(region: Region) {
|
||||
// if (cache[region]) return cache[region]!;
|
||||
title: string;
|
||||
icon: string | null;
|
||||
start_at: string;
|
||||
finish_at: string;
|
||||
current_season: number;
|
||||
updated_at: string;
|
||||
count: number;
|
||||
|
||||
// const response = await patientFetch(
|
||||
// context === 'website'
|
||||
// ? `/api/${region}/rating/current/info`
|
||||
// : `https://${regionToRegionSubdomain(
|
||||
// region,
|
||||
// )}.wotblitz.com/en/api/rating-leaderboards/season/`,
|
||||
// undefined,
|
||||
// );
|
||||
// const data = (await response.json()) as RatingInfo;
|
||||
rewards: RatingReward[];
|
||||
leagues: RatingLeague[];
|
||||
}
|
||||
| { detail: { error: string } };
|
||||
|
||||
// cache[region] = data;
|
||||
const cache: Partial<Record<Region, RatingInfo>> = {};
|
||||
|
||||
// return data;
|
||||
// }
|
||||
export async function getRatingInfo(region: Region) {
|
||||
if (cache[region]) return cache[region]!;
|
||||
|
||||
const response = await patientFetch(
|
||||
context === 'website'
|
||||
? `/api/${region}/rating/current/info`
|
||||
: `https://${regionToRegionSubdomain(
|
||||
region,
|
||||
)}.wotblitz.com/en/api/rating-leaderboards/season/`,
|
||||
undefined,
|
||||
);
|
||||
const data = (await response.json()) as RatingInfo;
|
||||
|
||||
cache[region] = data;
|
||||
|
||||
return data;
|
||||
}
|
||||
Reference in new issue
Block a user