Skip to content

Commit 86b6372

Browse files
authored
[Fix] Games with spaces in version name are always updateable (#503)
* add sanitize version on install * prettier * nullish operator and type fix * fix undefined check
1 parent 056c096 commit 86b6372

File tree

4 files changed

+20
-57
lines changed

4 files changed

+20
-57
lines changed

src/backend/storeManagers/hyperplay/games.ts

+10-4
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ import {
3939
import {
4040
getHyperPlayStoreRelease,
4141
handleArchAndPlatform,
42-
handlePlatformReversed
42+
handlePlatformReversed,
43+
sanitizeVersion
4344
} from './utils'
4445
import { getSettings as getSettingsSideload } from 'backend/storeManagers/sideload/games'
4546
import {
@@ -390,7 +391,12 @@ export async function install(
390391

391392
const [releaseMeta, selectedChannel] = getReleaseMeta(gameInfo, channelName)
392393

393-
const releaseVersion: string | undefined = releaseMeta.name
394+
const releaseVersion: string = sanitizeVersion(releaseMeta.name)
395+
const gameInfoVersion = gameInfo.version
396+
? sanitizeVersion(gameInfo.version)
397+
: ''
398+
399+
const installVersion = releaseVersion ?? gameInfoVersion ?? '0'
394400

395401
if (platformToInstall === 'Browser') {
396402
const browserGameInstalledInfo: InstalledInfo = {
@@ -399,7 +405,7 @@ export async function install(
399405
executable: '',
400406
install_size: '0',
401407
is_dlc: false,
402-
version: releaseVersion ? releaseVersion : gameInfo.version ?? '0',
408+
version: installVersion,
403409
platform: 'web',
404410
channelName
405411
}
@@ -489,7 +495,7 @@ export async function install(
489495
executable: executable,
490496
install_size: platformInfo.installSize ?? '0',
491497
is_dlc: false,
492-
version: releaseVersion ? releaseVersion : gameInfo.version ?? '0',
498+
version: installVersion,
493499
platform: appPlatform,
494500
channelName
495501
}

src/backend/storeManagers/hyperplay/library.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
getGameInfoFromHpRelease,
1414
getHyperPlayReleaseMap,
1515
handleArchAndPlatform,
16+
sanitizeVersion,
1617
refreshGameInfoFromHpRelease
1718
} from './utils'
1819
import { getGameInfo as getGamesGameInfo } from './games'
@@ -206,11 +207,12 @@ export async function listUpdateableGames(): Promise<string[]> {
206207
To continue to receive game updates, uninstall and reinstall this game: ${val.title}`)
207208
}
208209
if (
210+
// games installed before 0.5.0 used gameInfo.version for install.version
211+
// so for backwards compatibility we remove spaces and lower case channel release meta name here
209212
val.install.version !==
210-
val.channels[val.install.channelName].release_meta.name
211-
?.toLowerCase()
212-
.replaceAll(' ', '') ||
213-
''
213+
sanitizeVersion(
214+
val.channels[val.install.channelName].release_meta.name || ''
215+
)
214216
) {
215217
updateableGames.push(val.app_name)
216218
}

src/backend/storeManagers/hyperplay/utils.ts

+4
Original file line numberDiff line numberDiff line change
@@ -266,3 +266,7 @@ export async function loadEpicHyperPlayGameInfoMap() {
266266
}
267267
}
268268
}
269+
270+
export function sanitizeVersion(ver: string) {
271+
return ver.toLowerCase().replaceAll(' ', '')
272+
}

yarn.lock

-49
Original file line numberDiff line numberDiff line change
@@ -1594,25 +1594,13 @@
15941594
resolved "https://registry.yarnpkg.com/@fortawesome/fontawesome-common-types/-/fontawesome-common-types-6.2.0.tgz#76467a94aa888aeb22aafa43eb6ff889df3a5a7f"
15951595
integrity sha512-rBevIsj2nclStJ7AxTdfsa3ovHb1H+qApwrxcTVo+NNdeJiB9V75hsKfrkG5AwNcRUNxrPPiScGYCNmLMoh8pg==
15961596

1597-
"@fortawesome/fontawesome-common-types@6.4.2":
1598-
version "6.4.2"
1599-
resolved "https://registry.yarnpkg.com/@fortawesome/fontawesome-common-types/-/fontawesome-common-types-6.4.2.tgz#1766039cad33f8ad87f9467b98e0d18fbc8f01c5"
1600-
integrity sha512-1DgP7f+XQIJbLFCTX1V2QnxVmpLdKdzzo2k8EmvDOePfchaIGQ9eCHj2up3/jNEbZuBqel5OxiaOJf37TWauRA==
1601-
16021597
"@fortawesome/fontawesome-svg-core@^6.1.1":
16031598
version "6.2.0"
16041599
resolved "https://registry.yarnpkg.com/@fortawesome/fontawesome-svg-core/-/fontawesome-svg-core-6.2.0.tgz#11856eaf4dd1d865c442ddea1eed8ee855186ba2"
16051600
integrity sha512-Cf2mAAeMWFMzpLC7Y9H1I4o3wEU+XovVJhTiNG8ZNgSQj53yl7OCJaS80K4YjrABWZzbAHVaoHE1dVJ27AAYXw==
16061601
dependencies:
16071602
"@fortawesome/fontawesome-common-types" "6.2.0"
16081603

1609-
"@fortawesome/fontawesome-svg-core@^6.4.0":
1610-
version "6.4.2"
1611-
resolved "https://registry.yarnpkg.com/@fortawesome/fontawesome-svg-core/-/fontawesome-svg-core-6.4.2.tgz#37f4507d5ec645c8b50df6db14eced32a6f9be09"
1612-
integrity sha512-gjYDSKv3TrM2sLTOKBc5rH9ckje8Wrwgx1CxAPbN5N3Fm4prfi7NsJVWd1jklp7i5uSCVwhZS5qlhMXqLrpAIg==
1613-
dependencies:
1614-
"@fortawesome/fontawesome-common-types" "6.4.2"
1615-
16161604
"@fortawesome/free-brands-svg-icons@^6.1.1":
16171605
version "6.2.0"
16181606
resolved "https://registry.yarnpkg.com/@fortawesome/free-brands-svg-icons/-/free-brands-svg-icons-6.2.0.tgz#ce072179677f9b5d6767f918cfbf296f357cc1d0"
@@ -1627,41 +1615,20 @@
16271615
dependencies:
16281616
"@fortawesome/fontawesome-common-types" "6.2.0"
16291617

1630-
"@fortawesome/free-regular-svg-icons@^6.4.0":
1631-
version "6.4.2"
1632-
resolved "https://registry.yarnpkg.com/@fortawesome/free-regular-svg-icons/-/free-regular-svg-icons-6.4.2.tgz#aee79ed76ce5dd04931352f9d83700761b8b1b25"
1633-
integrity sha512-0+sIUWnkgTVVXVAPQmW4vxb9ZTHv0WstOa3rBx9iPxrrrDH6bNLsDYuwXF9b6fGm+iR7DKQvQshUH/FJm3ed9Q==
1634-
dependencies:
1635-
"@fortawesome/fontawesome-common-types" "6.4.2"
1636-
16371618
"@fortawesome/free-solid-svg-icons@^6.1.1":
16381619
version "6.2.0"
16391620
resolved "https://registry.yarnpkg.com/@fortawesome/free-solid-svg-icons/-/free-solid-svg-icons-6.2.0.tgz#8dcde48109354fd7a5ece8ea48d678bb91d4b5f0"
16401621
integrity sha512-UjCILHIQ4I8cN46EiQn0CZL/h8AwCGgR//1c4R96Q5viSRwuKVo0NdQEc4bm+69ZwC0dUvjbDqAHF1RR5FA3XA==
16411622
dependencies:
16421623
"@fortawesome/fontawesome-common-types" "6.2.0"
16431624

1644-
"@fortawesome/free-solid-svg-icons@^6.4.0":
1645-
version "6.4.2"
1646-
resolved "https://registry.yarnpkg.com/@fortawesome/free-solid-svg-icons/-/free-solid-svg-icons-6.4.2.tgz#33a02c4cb6aa28abea7bc082a9626b7922099df4"
1647-
integrity sha512-sYwXurXUEQS32fZz9hVCUUv/xu49PEJEyUOsA51l6PU/qVgfbTb2glsTEaJngVVT8VqBATRIdh7XVgV1JF1LkA==
1648-
dependencies:
1649-
"@fortawesome/fontawesome-common-types" "6.4.2"
1650-
16511625
"@fortawesome/react-fontawesome@^0.1.18":
16521626
version "0.1.19"
16531627
resolved "https://registry.yarnpkg.com/@fortawesome/react-fontawesome/-/react-fontawesome-0.1.19.tgz#2b36917578596f31934e71f92b7cf9c425fd06e4"
16541628
integrity sha512-Hyb+lB8T18cvLNX0S3llz7PcSOAJMLwiVKBuuzwM/nI5uoBw+gQjnf9il0fR1C3DKOI5Kc79pkJ4/xB0Uw9aFQ==
16551629
dependencies:
16561630
prop-types "^15.8.1"
16571631

1658-
"@fortawesome/react-fontawesome@^0.2.0":
1659-
version "0.2.0"
1660-
resolved "https://registry.yarnpkg.com/@fortawesome/react-fontawesome/-/react-fontawesome-0.2.0.tgz#d90dd8a9211830b4e3c08e94b63a0ba7291ddcf4"
1661-
integrity sha512-uHg75Rb/XORTtVt7OS9WoK8uM276Ufi7gCzshVWkUJbHhh3svsUUeqXerrM96Wm7fRiDzfKRwSoahhMIkGAYHw==
1662-
dependencies:
1663-
prop-types "^15.8.1"
1664-
16651632
"@humanwhocodes/config-array@^0.10.5":
16661633
version "0.10.7"
16671634
resolved "https://registry.yarnpkg.com/@humanwhocodes/config-array/-/config-array-0.10.7.tgz#6d53769fd0c222767e6452e8ebda825c22e9f0dc"
@@ -1681,13 +1648,6 @@
16811648
resolved "https://registry.yarnpkg.com/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz#b520529ec21d8e5945a1851dfd1c32e94e39ff45"
16821649
integrity sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==
16831650

1684-
"@hyperplay/chains@^0.0.2":
1685-
version "0.0.2"
1686-
resolved "https://registry.yarnpkg.com/@hyperplay/chains/-/chains-0.0.2.tgz#329aabdd30d5f1c25233fcb342840624fff235d1"
1687-
integrity sha512-yex3/IOnmxtM1N0uU20cceVKUDAjAGFO0LKNxH45Nn+bbOaVgXJCsXqEk3NfVLGk08X71fSDzRCcX2UCSUwEmA==
1688-
dependencies:
1689-
axios "^1.4.0"
1690-
16911651
"@hyperplay/ui@^0.1.14":
16921652
version "0.1.14"
16931653
resolved "https://registry.yarnpkg.com/@hyperplay/ui/-/ui-0.1.14.tgz#3af3752766978060063cbdb69aaa2b93ca14c16e"
@@ -4547,15 +4507,6 @@ axios@^1.0.0:
45474507
form-data "^4.0.0"
45484508
proxy-from-env "^1.1.0"
45494509

4550-
axios@^1.4.0:
4551-
version "1.5.0"
4552-
resolved "https://registry.yarnpkg.com/axios/-/axios-1.5.0.tgz#f02e4af823e2e46a9768cfc74691fdd0517ea267"
4553-
integrity sha512-D4DdjDo5CY50Qms0qGQTTw6Q44jl7zRwY7bthds06pUGfChBCTcQs+N743eFWGEd6pRTMd6A+I87aWyFV5wiZQ==
4554-
dependencies:
4555-
follow-redirects "^1.15.0"
4556-
form-data "^4.0.0"
4557-
proxy-from-env "^1.1.0"
4558-
45594510
babel-jest@^28.1.3:
45604511
version "28.1.3"
45614512
resolved "https://registry.yarnpkg.com/babel-jest/-/babel-jest-28.1.3.tgz#c1187258197c099072156a0a121c11ee1e3917d5"

0 commit comments

Comments
 (0)