Skip to content

Commit 019caee

Browse files
authored
[FIX] Image search on Add Game Screen blocking finish button (#2657)
[FIX] Image search on Add Game Screen
1 parent a8f740c commit 019caee

File tree

1 file changed

+13
-8
lines changed
  • src/frontend/screens/Library/components/InstallModal/SideloadDialog

1 file changed

+13
-8
lines changed

src/frontend/screens/Library/components/InstallModal/SideloadDialog/index.tsx

+13-8
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { AvailablePlatforms } from '..'
2121
import fallbackImage from 'frontend/assets/heroic_card.jpg'
2222
import ContextProvider from 'frontend/state/ContextProvider'
2323
import classNames from 'classnames'
24+
import axios from 'axios'
2425

2526
type Props = {
2627
availablePlatforms: AvailablePlatforms
@@ -50,7 +51,7 @@ export default function SideloadDialog({
5051
t('sideload.field.title', 'Title')
5152
)
5253
const [selectedExe, setSelectedExe] = useState('')
53-
const [imageUrl, setImageUrl] = useState(fallbackImage)
54+
const [imageUrl, setImageUrl] = useState('')
5455
const [searching, setSearching] = useState(false)
5556
const [app_name, setApp_name] = useState(appName ?? '')
5657
const [runningSetup, setRunningSetup] = useState(false)
@@ -115,20 +116,24 @@ export default function SideloadDialog({
115116
setSearching(true)
116117

117118
try {
118-
const res = await fetch(
119-
`https://steamgrid.usebottles.com/api/search/${title}`
119+
const response = await axios.get(
120+
`https://steamgrid.usebottles.com/api/search/${title}`,
121+
{ timeout: 3500 }
120122
)
121-
if (res.status === 200) {
122-
const steamGridImage = (await res.json()) as string
123+
124+
if (response.status === 200) {
125+
const steamGridImage = response.data as string
126+
123127
if (steamGridImage && steamGridImage.startsWith('http')) {
124128
setImageUrl(steamGridImage)
125129
}
126-
setSearching(false)
130+
} else {
131+
throw new Error('Fetch failed')
127132
}
128133
} catch (error) {
129-
console.error('Error when getting image from SteamGridDB')
130-
setSearching(false)
131134
window.api.logError(`${error}`)
135+
} finally {
136+
setSearching(false)
132137
}
133138
}
134139

0 commit comments

Comments
 (0)