mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-11 22:06:17 +00:00
feat: get game assets from stats
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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}
|
||||
/>
|
||||
|
||||
@@ -240,6 +240,7 @@ export interface DownloadSourceValidationResult {
|
||||
export interface GameStats {
|
||||
downloadCount: number;
|
||||
playerCount: number;
|
||||
assets: ShopAssets | null;
|
||||
}
|
||||
|
||||
export interface TrendingGame extends ShopAssets {
|
||||
|
||||
Reference in New Issue
Block a user