diff --git a/package.json b/package.json index 078d252..1187b5c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "protondb-decky", - "version": "1.0.2", + "version": "1.0.3", "description": "Display tappable ProtonDB badges on your game pages", "scripts": { "build": "shx rm -rf dist && rollup -c", diff --git a/src/actions/protondb.ts b/src/actions/protondb.ts index 63e35fa..cfcba24 100644 --- a/src/actions/protondb.ts +++ b/src/actions/protondb.ts @@ -4,7 +4,7 @@ import ProtonDBTier from '../../types/ProtonDBTier' export async function getProtonDBInfo( serverAPI: ServerAPI, appId: string -): Promise { +): Promise { const req = { method: 'GET', url: `https://www.protondb.com/api/v1/reports/summaries/${appId}.json` @@ -15,9 +15,8 @@ export async function getProtonDBInfo( >('http_request', req) if (res.success && res.result.status === 200) { return JSON.parse(res.result?.body).tier - } else { - return 'pending' } + return undefined } export async function getLinuxInfo( diff --git a/src/hooks/useBadgeData.ts b/src/hooks/useBadgeData.ts index a044245..5889310 100644 --- a/src/hooks/useBadgeData.ts +++ b/src/hooks/useBadgeData.ts @@ -23,18 +23,21 @@ const useBadgeData = (serverAPI: ServerAPI, appId: string | undefined) => { () => false ) const [tier, linuxSupport] = await Promise.all([tierPromise, linuxPromise]) - cacheDispatch({ - type: 'update-cache', - value: { - appId: appId as string, - data: { - tier: tier, - linuxSupport, - lastUpdated: new Date().toISOString() + if (tier?.length) { + cacheDispatch({ + type: 'update-cache', + value: { + appId: appId as string, + data: { + tier: tier, + linuxSupport, + lastUpdated: new Date().toISOString() + } } - } - }) - setProtonDBTier(tier) + }) + setProtonDBTier(tier) + } + setLinuxSupport(linuxSupport) } useEffect(() => { @@ -49,6 +52,7 @@ const useBadgeData = (serverAPI: ServerAPI, appId: string | undefined) => { if (ignore) { return } + if (!tier?.length) return setProtonDBTier(tier) } if (appId?.length && !cacheLoading) {