Skip to content

Commit

Permalink
[Fix] Handle possible undefined GOG images (#3373)
Browse files Browse the repository at this point in the history
Handle possible undefined gog images
  • Loading branch information
arielj authored Jan 2, 2024
1 parent d68ea7c commit a03b38b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
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

0 comments on commit a03b38b

Please sign in to comment.