feat: route adjustment

This commit is contained in:
Zamitto 2024-09-29 11:36:44 -03:00
parent eda47fc6af
commit 333b143b17
2 changed files with 15 additions and 8 deletions

View File

@ -6,6 +6,7 @@ import {
gameRepository,
userPreferencesRepository,
} from "@main/repository";
import { UserNotLoggedInError } from "@shared";
const getGameAchievements = async (
_event: Electron.IpcMainInvokeEvent,
@ -22,11 +23,11 @@ const getGameAchievements = async (
}),
]);
const apiAchievement = HydraApi.get(
"/games/achievements",
{ objectId, shop, language: userPreferences?.language || "en" },
{ needsAuth: false }
)
const apiAchievement = HydraApi.get("/games/achievements", {
objectId,
shop,
language: userPreferences?.language || "en",
})
.then((achievements) => {
if (game) {
gameAchievementRepository.upsert(
@ -41,7 +42,10 @@ const getGameAchievements = async (
return achievements;
})
.catch(() => []);
.catch((err) => {
if (err instanceof UserNotLoggedInError) throw err;
return [];
});
const gameAchievements = cachedAchievements?.achievements
? JSON.parse(cachedAchievements.achievements)

View File

@ -145,7 +145,9 @@ export function GameDetailsContextProvider({
.then((achievements) => {
setAchievements(achievements);
})
.catch(() => {});
.catch(() => {
// TODO: handle user not logged in error
});
updateGame();
}, [updateGame, dispatch, gameTitle, objectID, shop, i18n.language]);
@ -183,7 +185,8 @@ export function GameDetailsContextProvider({
window.electron
.getGameAchievements(objectID!, shop as GameShop)
.then(setAchievements);
.then(setAchievements)
.catch(() => {});
}
);