Game profile: upstream failure logs and retry affordance
- Log Steam, ITAD and detectables upstream failures with status codes for diagnosis - Show retry affordance when all profile sources come back empty or the load fails
This commit is contained in:
5 files changed
+43
-2
No files matched your search
@@ -108,6 +108,7 @@ export function GameProfileModal({
|
||||
}) {
|
||||
const [profile, setProfile] = useState<GameProfile | null>(null);
|
||||
const [failed, setFailed] = useState(false);
|
||||
const [attempt, setAttempt] = useState(0);
|
||||
const [bannerPick, setBannerPick] = useState<string | null>(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({
|
||||
<p className="mt-4 animate-pulse text-sm text-zinc-500">{dict.loading}</p>
|
||||
) : null}
|
||||
{failed && !profile ? (
|
||||
<p className="mt-4 text-sm text-zinc-500">{dict.loadError}</p>
|
||||
<div className="mt-4 flex items-center gap-3 text-sm text-zinc-500">
|
||||
<p>{dict.loadError}</p>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => {
|
||||
setFailed(false);
|
||||
setAttempt((n) => n + 1);
|
||||
}}
|
||||
className="shrink-0 cursor-pointer rounded-full border border-white/10 px-3 py-1 text-xs text-zinc-300 transition-colors hover:border-white/25 hover:text-white"
|
||||
>
|
||||
{dict.retry}
|
||||
</button>
|
||||
</div>
|
||||
) : null}
|
||||
{partialFail ? (
|
||||
<div className="mt-4 flex items-center gap-3 rounded-xl border border-white/5 bg-white/[0.03] p-3 text-sm text-zinc-400">
|
||||
<p className="flex-1">{dict.partialFail}</p>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => {
|
||||
setProfile(null);
|
||||
setAttempt((n) => n + 1);
|
||||
}}
|
||||
className="shrink-0 cursor-pointer rounded-full border border-white/10 px-3 py-1 text-xs text-zinc-300 transition-colors hover:border-white/25 hover:text-white"
|
||||
>
|
||||
{dict.retry}
|
||||
</button>
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
{profile?.description ? (
|
||||
|
||||
Reference in new issue
Block a user