Skip to content

Commit 1c91af4

Browse files
authored
[GOG]: don't check for notInstallable during library sync (#3711)
* fix: don't check for notInstallable during library sync * fix: lint * improv: remove product info fetching for library sync alltogether * fix: gogStoreUrl undefined * fix: use proper titles
1 parent 12c7188 commit 1c91af4

File tree

6 files changed

+79
-44
lines changed

6 files changed

+79
-44
lines changed

src/backend/storeManagers/gog/games.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,19 +119,22 @@ export async function getExtraInfo(appName: string): Promise<ExtraInfo> {
119119

120120
const gamesData = await getGamesData(appName)
121121

122-
const gogStoreUrl = gamesData?._links?.store.href
122+
let gogStoreUrl = gamesData?._links?.store.href
123123
const releaseDate =
124124
gamesData?._embedded.product?.globalReleaseDate?.substring(0, 19)
125125

126-
const storeUrl = new URL(gogStoreUrl)
127-
storeUrl.hostname = 'af.gog.com'
128-
storeUrl.searchParams.set('as', '1838482841')
126+
if (gogStoreUrl) {
127+
const storeUrl = new URL(gogStoreUrl)
128+
storeUrl.hostname = 'af.gog.com'
129+
storeUrl.searchParams.set('as', '1838482841')
130+
gogStoreUrl = storeUrl.toString()
131+
}
129132

130133
const extra: ExtraInfo = {
131134
about: gameInfo.extra?.about,
132135
reqs,
133136
releaseDate,
134-
storeUrl: storeUrl.toString(),
137+
storeUrl: gogStoreUrl,
135138
changelog: productInfo?.data.changelog
136139
}
137140
return extra

src/backend/storeManagers/gog/library.ts

Lines changed: 30 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -404,13 +404,7 @@ export async function refresh(): Promise<ExecResult> {
404404
continue
405405
}
406406

407-
const product = await getProductApi(
408-
game.external_id,
409-
[],
410-
credentials.access_token
411-
).catch(() => null)
412-
413-
const unifiedObject = await gogToUnifiedInfo(gdbData, product?.data)
407+
const unifiedObject = await gogToUnifiedInfo(gdbData)
414408
if (unifiedObject.app_name) {
415409
const oldData = library.get(unifiedObject.app_name)
416410
if (oldData) {
@@ -575,6 +569,28 @@ export async function getInstallInfo(
575569
`stdout = ${!!res.stdout} and res.abort = ${!!res.abort} in getInstallInfo`,
576570
LogPrefix.Gog
577571
)
572+
if (res.stderr.includes("Game doesn't support content system api")) {
573+
return {
574+
game: {
575+
app_name: appName,
576+
title: gameData.title,
577+
launch_options: [],
578+
owned_dlc: [],
579+
version: '',
580+
branches: [],
581+
buildId: ''
582+
},
583+
manifest: {
584+
app_name: appName,
585+
disk_size: 0,
586+
download_size: 0,
587+
languages: [],
588+
versionEtag: '',
589+
dependencies: [],
590+
perLangSize: { '*': { download_size: 0, disk_size: 0 } }
591+
}
592+
}
593+
}
578594
return
579595
}
580596

@@ -921,29 +937,19 @@ export async function checkForGameUpdate(
921937
* That way it will be easly accessible on frontend
922938
*/
923939
export async function gogToUnifiedInfo(
924-
info: GamesDBData | undefined,
925-
galaxyProductInfo: ProductsEndpointData | undefined
940+
info: GamesDBData | undefined
926941
): Promise<GameInfo> {
927-
if (
928-
!info ||
929-
info.type === 'dlc' ||
930-
!info.game.visible_in_library ||
931-
(galaxyProductInfo &&
932-
!galaxyProductInfo.is_installable &&
933-
galaxyProductInfo.game_type !== 'game')
934-
) {
942+
if (!info || info.type !== 'game' || !info.game.visible_in_library) {
935943
// @ts-expect-error TODO: Handle this somehow
936944
return {}
937945
}
938946

939-
const art_cover =
940-
info.game?.logo?.url_format
941-
?.replace('{formatter}', '')
942-
.replace('{ext}', 'jpg') || `https:${galaxyProductInfo?.images.logo2x}`
947+
const art_cover = info.game?.logo?.url_format
948+
?.replace('{formatter}', '')
949+
.replace('{ext}', 'jpg')
943950

944951
const object: GameInfo = {
945952
runner: 'gog',
946-
store_url: galaxyProductInfo?.links.product_card,
947953
developer: info.game.developers.map((dev) => dev.name).join(', '),
948954
app_name: String(info.external_id),
949955
art_cover,
@@ -957,22 +963,15 @@ export async function gogToUnifiedInfo(
957963
cloud_save_enabled: false,
958964
extra: {
959965
about: { description: info.summary['*'], shortDescription: '' },
960-
reqs: [],
961-
storeUrl: galaxyProductInfo?.links.product_card
966+
reqs: []
962967
},
963968
folder_name: '',
964969
install: {
965970
is_dlc: false
966971
},
967-
installable:
968-
(galaxyProductInfo?.content_system_compatibility.osx ||
969-
galaxyProductInfo?.content_system_compatibility.windows ||
970-
galaxyProductInfo?.content_system_compatibility.linux) ??
971-
false,
972972
is_installed: false,
973-
namespace: galaxyProductInfo?.slug,
974973
save_folder: '',
975-
title: (galaxyProductInfo?.title ?? info.game.title['en-US'] ?? '').trim(),
974+
title: ((info.title['*'] || info.game.title['*']) ?? '').trim(),
976975
canRunOffline: true,
977976
is_mac_native: Boolean(
978977
info.supported_operating_systems.find((os) => os.slug === 'osx')

src/frontend/screens/Game/GamePage/components/DownloadSizeInfo.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,6 @@ const DownloadSizeInfo = ({ gameInfo }: Props) => {
3131
return null
3232
}
3333

34-
if (gameInfo.installable !== undefined && !gameInfo.installable) {
35-
return null
36-
}
37-
3834
const downloadSize =
3935
gameInstallInfo?.manifest?.download_size &&
4036
size(Number(gameInstallInfo?.manifest?.download_size))

src/frontend/screens/Game/GamePage/index.tsx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ export default React.memo(function GamePage(): JSX.Element | null {
111111
const [progress, previousProgress] = hasProgress(appName)
112112

113113
const [extraInfo, setExtraInfo] = useState<ExtraInfo | null>(null)
114+
const [notInstallable, setNotInstallable] = useState<boolean>(false)
114115
const [gameInstallInfo, setGameInstallInfo] = useState<InstallInfo | null>(
115116
null
116117
)
@@ -142,8 +143,6 @@ export default React.memo(function GamePage(): JSX.Element | null {
142143
const isInstallingWinetricksPackages = status === 'winetricks'
143144
const isInstallingRedist = status === 'redist'
144145
const notAvailable = !gameAvailable && gameInfo.is_installed
145-
const notInstallable =
146-
gameInfo.installable !== undefined && !gameInfo.installable
147146
const notSupportedGame =
148147
gameInfo.runner !== 'sideload' && gameInfo.thirdPartyManagedApp === 'Origin'
149148
const isOffline = connectivity.status !== 'online'
@@ -172,6 +171,7 @@ export default React.memo(function GamePage(): JSX.Element | null {
172171
if (gameInfo && status) {
173172
const {
174173
install,
174+
is_installed,
175175
is_linux_native = undefined,
176176
is_mac_native = undefined
177177
} = { ...gameInfo }
@@ -186,6 +186,7 @@ export default React.memo(function GamePage(): JSX.Element | null {
186186

187187
if (
188188
runner !== 'sideload' &&
189+
!is_installed &&
189190
!notSupportedGame &&
190191
!notInstallable &&
191192
!isOffline
@@ -195,6 +196,13 @@ export default React.memo(function GamePage(): JSX.Element | null {
195196
if (!info) {
196197
throw 'Cannot get game info'
197198
}
199+
if (
200+
info.manifest.disk_size === 0 &&
201+
info.manifest.download_size === 0
202+
) {
203+
setNotInstallable(true)
204+
return
205+
}
198206
setGameInstallInfo(info)
199207
})
200208
.catch((error) => {
@@ -381,7 +389,9 @@ export default React.memo(function GamePage(): JSX.Element | null {
381389
/>
382390
<Description />
383391
<CloudSavesSync gameInfo={gameInfo} />
384-
<DownloadSizeInfo gameInfo={gameInfo} />
392+
{!notInstallable && (
393+
<DownloadSizeInfo gameInfo={gameInfo} />
394+
)}
385395
<InstalledInfo gameInfo={gameInfo} />
386396
<Scores gameInfo={gameInfo} />
387397
<HLTB />

src/frontend/screens/Library/components/GameCard/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import StoreLogos from 'frontend/components/UI/StoreLogos'
3939
import UninstallModal from 'frontend/components/UI/UninstallModal'
4040
import { getCardStatus, getImageFormatting } from './constants'
4141
import { hasStatus } from 'frontend/hooks/hasStatus'
42+
import fallBackImage from 'frontend/assets/heroic_card.jpg'
4243
import LibraryContext from '../../LibraryContext'
4344

4445
interface Card {
@@ -411,7 +412,7 @@ const GameCard = ({
411412
<StoreLogos runner={runner} />
412413
{justPlayed ? (
413414
<CachedImage
414-
src={art_cover}
415+
src={art_cover || fallBackImage}
415416
className="justPlayedImg"
416417
alt={title}
417418
/>

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,32 @@ export default function DownloadDialog({
274274
selectedBuild,
275275
branch
276276
)
277+
278+
if (
279+
gameInstallInfo?.manifest.disk_size === 0 &&
280+
gameInstallInfo.manifest.download_size === 0
281+
) {
282+
showDialogModal({
283+
showDialog: true,
284+
title: t(
285+
'label.game.not-installable-game',
286+
'Game is NOT Installable'
287+
),
288+
message: t(
289+
'status.gog-goodie',
290+
"This game doesn't appear to be installable. Check downloadable content on https://gog.com/account"
291+
),
292+
buttons: [
293+
{
294+
text: tr('box.ok')
295+
}
296+
],
297+
type: 'MESSAGE'
298+
})
299+
backdropClick()
300+
return
301+
}
302+
277303
setGameInstallInfo(gameInstallInfo)
278304
setGettingInstallInfo(false)
279305

0 commit comments

Comments
 (0)