feat: get game assets from stats

This commit is contained in:
Zamitto
2025-05-08 09:19:12 -03:00
parent 48e9536169
commit cf818d0f4f
3 changed files with 15 additions and 10 deletions

View File

@@ -120,7 +120,7 @@ export function GameDetailsContextProvider({
const abortController = new AbortController();
abortControllerRef.current = abortController;
window.electron
const shopDetailsPromise = window.electron
.getGameShopDetails(objectId, shop, getSteamLanguage(i18n.language))
.then((result) => {
if (abortController.signal.aborted) return;
@@ -135,15 +135,18 @@ export function GameDetailsContextProvider({
) {
setHasNSFWContentBlocked(true);
}
})
.finally(() => {
if (abortController.signal.aborted) return;
setIsLoading(false);
});
window.electron.getGameStats(objectId, shop).then((result) => {
const statsPromise = window.electron
.getGameStats(objectId, shop)
.then((result) => {
if (abortController.signal.aborted) return;
setStats(result);
});
Promise.all([shopDetailsPromise, statsPromise]).finally(() => {
if (abortController.signal.aborted) return;
setStats(result);
setIsLoading(false);
});
if (userDetails) {

View File

@@ -24,6 +24,7 @@ export function GameDetailsContent() {
const {
objectId,
shopDetails,
stats,
game,
gameColor,
setGameColor,
@@ -59,7 +60,7 @@ export function GameDetailsContent() {
const [backdropOpacity, setBackdropOpacity] = useState(1);
const handleHeroLoad = async () => {
const output = await average(shopDetails?.libraryHeroImageUrl ?? "", {
const output = await average(stats?.assets?.libraryHeroImageUrl ?? "", {
amount: 1,
format: "hex",
});
@@ -100,7 +101,7 @@ export function GameDetailsContent() {
<section className="game-details__container">
<div ref={heroRef} className="game-details__hero">
<img
src={shopDetails?.libraryHeroImageUrl ?? ""}
src={stats?.assets?.libraryHeroImageUrl ?? ""}
className="game-details__hero-image"
alt={game?.title}
onLoad={handleHeroLoad}
@@ -119,7 +120,7 @@ export function GameDetailsContent() {
>
<div className="game-details__hero-content">
<img
src={shopDetails?.logoImageUrl ?? ""}
src={stats?.assets?.logoImageUrl ?? ""}
className="game-details__game-logo"
alt={game?.title}
/>

View File

@@ -240,6 +240,7 @@ export interface DownloadSourceValidationResult {
export interface GameStats {
downloadCount: number;
playerCount: number;
assets: ShopAssets | null;
}
export interface TrendingGame extends ShopAssets {