Skip to content

Commit 5592df7

Browse files
authored
Remove duplicate game infos during migration (#476)
1 parent 3bfc98c commit 5592df7

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

src/backend/storeManagers/hyperplay/electronStore.ts

+20-6
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,26 @@ export const hpLibraryStore = new TypeCheckedStoreBackend('hpLibraryStore', {
3333
return game
3434
}
3535

36-
const newLibrary = currentLibrary.map((game) => {
37-
//game was previously listed so we map its previous app_name to its new project_id
38-
if (Object.hasOwn(appNameToProjectIdMap, game.app_name))
39-
game.app_name = appNameToProjectIdMap[game.app_name]
40-
return updateGameInfo(game)
41-
})
36+
const newLibrary = currentLibrary
37+
.filter((game) => {
38+
// remove the game info with the old app id if a game info exists with the new app id
39+
const newProjectId = appNameToProjectIdMap[game.app_name]
40+
if (newProjectId === undefined) return true
41+
const newGameInfoExists =
42+
currentLibrary.findIndex((val) => val.app_name === newProjectId) >=
43+
0
44+
if (newGameInfoExists) {
45+
return false
46+
}
47+
48+
return true
49+
})
50+
.map((game) => {
51+
//game was previously listed so we map its previous app_name to its new project_id
52+
if (Object.hasOwn(appNameToProjectIdMap, game.app_name))
53+
game.app_name = appNameToProjectIdMap[game.app_name]
54+
return updateGameInfo(game)
55+
})
4256

4357
store.set('games', newLibrary)
4458
}

0 commit comments

Comments
 (0)