Skip to content

Commit

Permalink
Remove game from Custom IDs Overrides list if plugin can not find it …
Browse files Browse the repository at this point in the history
…in user library
  • Loading branch information
ynhhoJ committed Aug 26, 2024
1 parent 3cf2b41 commit b21ec32
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
11 changes: 11 additions & 0 deletions src/ts/AchievementsManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,17 @@ export class AchievementManager implements Manager
return false;
})

// NOTE: Checks for games what does not exists in user library and removes them from
// `cache` configuration
const gameIdsToBeRemoved = Object.keys(this.customIdsOverrides)
.filter((appId) => !allNonSteamAppIds.includes(Number.parseInt(appId, 10)));

for (const gameIdToBeRemoved of gameIdsToBeRemoved) {
const gameIdToBeRemovedAsNumber = Number.parseInt(gameIdToBeRemoved, 10);

delete this.ids[gameIdToBeRemovedAsNumber]
delete this.customIdsOverrides[gameIdToBeRemovedAsNumber]
}

await this.refreshAchievementsForApps(nonSteamAppIdsWithRetroAchievementId);
}
Expand Down
6 changes: 3 additions & 3 deletions src/ts/components/settingsComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ const CustomIdsOverrides: VFC = () => {
const { custom_ids_overrides }= emuchievementsState.settings.data.cache;
const gameOptions = Object.keys(custom_ids_overrides)
.map((item) => {
const idAsNumber = Number.parseInt(item);
const idAsNumber = Number.parseInt(item, 10);
const currentApp = custom_ids_overrides[idAsNumber];

return {
Expand Down Expand Up @@ -190,7 +190,7 @@ const CustomIdsOverrides: VFC = () => {
continue
}

const appIdAsNumber = Number.parseInt(appId);
const appIdAsNumber = Number.parseInt(appId, 10);

if (!retroAchievementAppId) {
emuchievementsState.settings.data.cache.custom_ids_overrides[appIdAsNumber] = {
Expand All @@ -202,7 +202,7 @@ const CustomIdsOverrides: VFC = () => {
continue;
}

const retroAchievementAppIdAsNumber = Number.parseInt(retroAchievementAppId);
const retroAchievementAppIdAsNumber = Number.parseInt(retroAchievementAppId, 10);

if (Number.isNaN(retroAchievementAppIdAsNumber) || retroAchievementAppIdAsNumber <= 0) {
emuchievementsState.settings.data.cache.custom_ids_overrides[appIdAsNumber] = {
Expand Down

0 comments on commit b21ec32

Please sign in to comment.