mirror of
https://github.com/lexogrine/cs2-react-hud.git
synced 2026-05-04 04:03:10 +02:00
initial commit
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
import api from './api';
|
||||
interface AvatarLoader {
|
||||
loader: Promise<string>,
|
||||
url: string,
|
||||
}
|
||||
|
||||
export const avatars: { [key: string]: AvatarLoader } = {};
|
||||
|
||||
export const loadAvatarURL = (steamid: string) => {
|
||||
if(!steamid) return;
|
||||
if(avatars[steamid]) return avatars[steamid].url;
|
||||
avatars[steamid] = {
|
||||
url: '',
|
||||
loader: new Promise((resolve) => {
|
||||
api.players.getAvatarURLs(steamid).then(result => {
|
||||
avatars[steamid].url = result.custom || result.steam;
|
||||
resolve(result.custom || result.custom);
|
||||
}).catch(() => {
|
||||
delete avatars[steamid];
|
||||
resolve('');
|
||||
});
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user