Skip to content

[FIX] Image search on Add Game Screen blocking finish button #2657

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { AvailablePlatforms } from '..'
import fallbackImage from 'frontend/assets/heroic_card.jpg'
import ContextProvider from 'frontend/state/ContextProvider'
import classNames from 'classnames'
import axios from 'axios'

type Props = {
availablePlatforms: AvailablePlatforms
Expand Down Expand Up @@ -50,7 +51,7 @@ export default function SideloadDialog({
t('sideload.field.title', 'Title')
)
const [selectedExe, setSelectedExe] = useState('')
const [imageUrl, setImageUrl] = useState(fallbackImage)
const [imageUrl, setImageUrl] = useState('')
const [searching, setSearching] = useState(false)
const [app_name, setApp_name] = useState(appName ?? '')
const [runningSetup, setRunningSetup] = useState(false)
Expand Down Expand Up @@ -115,20 +116,24 @@ export default function SideloadDialog({
setSearching(true)

try {
const res = await fetch(
`https://steamgrid.usebottles.com/api/search/${title}`
const response = await axios.get(
`https://steamgrid.usebottles.com/api/search/${title}`,
{ timeout: 3500 }
)
if (res.status === 200) {
const steamGridImage = (await res.json()) as string

if (response.status === 200) {
const steamGridImage = response.data as string

if (steamGridImage && steamGridImage.startsWith('http')) {
setImageUrl(steamGridImage)
}
setSearching(false)
} else {
throw new Error('Fetch failed')
}
} catch (error) {
console.error('Error when getting image from SteamGridDB')
setSearching(false)
window.api.logError(`${error}`)
} finally {
setSearching(false)
}
}

Expand Down