Skip to content
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

[Fix] Handle possible undefined GOG images #3373

Merged
merged 1 commit into from
Jan 2, 2024
Merged
Show file tree
Hide file tree
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
20 changes: 12 additions & 8 deletions src/backend/storeManagers/gog/library.ts
Original file line number Diff line number Diff line change
Expand Up @@ -653,19 +653,23 @@ export async function gogToUnifiedInfo(
// @ts-expect-error TODO: Handle this somehow
return {}
}

const art_cover =
info.game?.logo?.url_format
?.replace('{formatter}', '')
.replace('{ext}', 'jpg') || `https:${galaxyProductInfo?.images.logo2x}`

const object: GameInfo = {
runner: 'gog',
store_url: galaxyProductInfo?.links.product_card,
developer: info.game.developers.map((dev) => dev.name).join(', '),
app_name: String(info.external_id),
art_cover:
info.game?.logo?.url_format
?.replace('{formatter}', '')
.replace('{ext}', 'jpg') || `https:${galaxyProductInfo?.images.logo2x}`,
art_square: info.game.vertical_cover.url_format
.replace('{formatter}', '')
.replace('{ext}', 'jpg'),
art_background: info.game.background.url_format
art_cover,
art_square:
info.game.vertical_cover?.url_format
.replace('{formatter}', '')
.replace('{ext}', 'jpg') || art_cover, // fallback to art_cover if undefined
art_background: info.game.background?.url_format
.replace('{formatter}', '')
.replace('{ext}', 'webp'),
cloud_save_enabled: false,
Expand Down
4 changes: 2 additions & 2 deletions src/common/types/gog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,10 +231,10 @@ interface GamesDBDataInner extends GamesDBDataBase {
horizontal_artwork: {
url_format: string
}
background: {
background?: {
url_format: string
}
vertical_cover: {
vertical_cover?: {
url_format: string
}
cover: {
Expand Down