feat: handle empty response on update achievements

This commit is contained in:
Zamitto
2025-04-13 08:10:52 -03:00
parent 8db03bcccf
commit e0c6d2fe3d
3 changed files with 24 additions and 8 deletions

View File

@@ -2,6 +2,7 @@ import type {
Game,
GameShop,
UnlockedAchievement,
UpdatedUnlockedAchievements,
UserPreferences,
} from "@types";
import { WindowManager } from "../window-manager";
@@ -115,7 +116,7 @@ export const mergeAchievements = async (
}
if (game.remoteId) {
await HydraApi.put(
await HydraApi.put<UpdatedUnlockedAchievements | undefined>(
"/profile/games/achievements",
{
id: game.remoteId,
@@ -124,10 +125,19 @@ export const mergeAchievements = async (
{ needsSubscription: !newAchievements.length }
)
.then((response) => {
if (response) {
return saveAchievementsOnLocal(
response.objectId,
response.shop,
response.achievements,
publishNotification
);
}
return saveAchievementsOnLocal(
response.objectId,
response.shop,
response.achievements,
game.objectId,
game.shop,
mergedLocalAchievements,
publishNotification
);
})