diff --git a/components/game-profile-modal.tsx b/components/game-profile-modal.tsx index c508b2e..7100f89 100644 --- a/components/game-profile-modal.tsx +++ b/components/game-profile-modal.tsx @@ -108,6 +108,7 @@ export function GameProfileModal({ }) { const [profile, setProfile] = useState(null); const [failed, setFailed] = useState(false); + const [attempt, setAttempt] = useState(0); const [bannerPick, setBannerPick] = useState(null); const tag = LOCALE_TAGS[lang] ?? "en-US"; const country = COUNTRIES[lang] ?? "US"; @@ -125,6 +126,7 @@ export function GameProfileModal({ const json = (await response.json()) as GameProfile; if (!cancelled) { setProfile(json); + setFailed(false); } } catch { if (!cancelled) { @@ -136,7 +138,9 @@ export function GameProfileModal({ return () => { cancelled = true; }; - }, [applicationId, lang, country]); + }, [applicationId, lang, country, attempt]); + const partialFail = + !!profile && !profile.sources.igdb && !profile.sources.steam && !profile.sources.itad; useEffect(() => { function onKey(event: KeyboardEvent): void { @@ -292,7 +296,34 @@ export function GameProfileModal({

{dict.loading}

) : null} {failed && !profile ? ( -

{dict.loadError}

+
+

{dict.loadError}

+ +
+ ) : null} + {partialFail ? ( +
+

{dict.partialFail}

+ +
) : null} {profile?.description ? ( diff --git a/lib/game-profile.ts b/lib/game-profile.ts index ebcb3a3..c39c25d 100644 --- a/lib/game-profile.ts +++ b/lib/game-profile.ts @@ -92,6 +92,7 @@ async function getDetectables(): Promise { next: { revalidate: 86_400 }, }); if (!response.ok) { + console.error(`detectables failed: ${response.status}`); return detectablesCache?.data ?? []; } const data = (await response.json()) as DetectableEntry[]; @@ -153,6 +154,7 @@ async function getSteamDetails( { next: { revalidate: 86_400 } }, ); if (!response.ok) { + console.error(`steam details failed: ${steamId} ${response.status}`); return null; } const json = (await response.json()) as Record; @@ -177,6 +179,7 @@ async function getSteamReviewSummary(steamId: string): Promise(path: string, init?: RequestInit): Promise }, ); if (!response.ok) { + console.error(`itad failed: ${path.split("?")[0]} ${response.status}`); return null; } return (await response.json()) as T; diff --git a/lib/i18n/dictionaries/de.json b/lib/i18n/dictionaries/de.json index 9043fd5..74d9c50 100644 --- a/lib/i18n/dictionaries/de.json +++ b/lib/i18n/dictionaries/de.json @@ -46,6 +46,8 @@ "openOnIgdb": "IGDB", "loading": "Spieldaten werden geladen...", "loadError": "Spieldaten konnten nicht geladen werden.", + "retry": "Erneut versuchen", + "partialFail": "Einige Daten konnten nicht geladen werden.", "screenshots": "Screenshots", "reviewsUnit": "Bewertungen", "scrollBack": "Zurück", diff --git a/lib/i18n/dictionaries/en.json b/lib/i18n/dictionaries/en.json index 10151ae..c29bc89 100644 --- a/lib/i18n/dictionaries/en.json +++ b/lib/i18n/dictionaries/en.json @@ -46,6 +46,8 @@ "openOnIgdb": "IGDB", "loading": "Loading game info...", "loadError": "Couldn't load game info.", + "retry": "Retry", + "partialFail": "Some data failed to load.", "screenshots": "Screenshots", "reviewsUnit": "reviews", "scrollBack": "Back", diff --git a/lib/i18n/dictionaries/tr.json b/lib/i18n/dictionaries/tr.json index 8fc1e28..7840c4e 100644 --- a/lib/i18n/dictionaries/tr.json +++ b/lib/i18n/dictionaries/tr.json @@ -46,6 +46,8 @@ "openOnIgdb": "IGDB", "loading": "Oyun bilgileri yükleniyor...", "loadError": "Oyun bilgileri yüklenemedi.", + "retry": "Tekrar Dene", + "partialFail": "Bazı veriler yüklenemedi.", "screenshots": "Görseller", "reviewsUnit": "değerlendirme", "scrollBack": "Geri",