Skip to content

Commit

Permalink
Merge pull request #37 from OMGDuke/staging
Browse files Browse the repository at this point in the history
v1.0.3 Release
  • Loading branch information
OMGDuke authored Aug 22, 2022
2 parents ca2569d + 0c2dd4e commit a40bb5a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 15 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
5 changes: 2 additions & 3 deletions src/actions/protondb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import ProtonDBTier from '../../types/ProtonDBTier'
export async function getProtonDBInfo(
serverAPI: ServerAPI,
appId: string
): Promise<ProtonDBTier> {
): Promise<ProtonDBTier | undefined> {
const req = {
method: 'GET',
url: `https://www.protondb.com/api/v1/reports/summaries/${appId}.json`
Expand All @@ -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(
Expand Down
26 changes: 15 additions & 11 deletions src/hooks/useBadgeData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand All @@ -49,6 +52,7 @@ const useBadgeData = (serverAPI: ServerAPI, appId: string | undefined) => {
if (ignore) {
return
}
if (!tier?.length) return
setProtonDBTier(tier)
}
if (appId?.length && !cacheLoading) {
Expand Down

0 comments on commit a40bb5a

Please sign in to comment.