fix: issues

This commit is contained in:
Zamitto 2024-12-31 14:06:27 -03:00
parent cbbe6993bd
commit ad204e3879
4 changed files with 12 additions and 17 deletions

View File

@ -9,6 +9,8 @@ const getSessionHash = async (_event: Electron.IpcMainInvokeEvent) => {
if (!auth) return null; if (!auth) return null;
const payload = jwt.decode(auth.accessToken) as jwt.JwtPayload; const payload = jwt.decode(auth.accessToken) as jwt.JwtPayload;
if (!payload) return null;
return payload.sessionId; return payload.sessionId;
}; };

View File

@ -1,7 +1,7 @@
import { HydraApi } from "@main/services"; import { HydraApi } from "@main/services";
import { registerEvent } from "../register-event"; import { registerEvent } from "../register-event";
import type { GameArtifact, GameShop } from "@types"; import type { GameArtifact, GameShop } from "@types";
import { SubscriptionRequiredError } from "@shared"; import { SubscriptionRequiredError, UserNotLoggedInError } from "@shared";
const getGameArtifacts = async ( const getGameArtifacts = async (
_event: Electron.IpcMainInvokeEvent, _event: Electron.IpcMainInvokeEvent,
@ -22,6 +22,10 @@ const getGameArtifacts = async (
return []; return [];
} }
if (err instanceof UserNotLoggedInError) {
return [];
}
throw err; throw err;
}); });
}; };

View File

@ -1,16 +1,10 @@
import { shell } from "electron"; import { shell } from "electron";
import { registerEvent } from "../register-event"; import { registerEvent } from "../register-event";
import { import { userAuthRepository } from "@main/repository";
userAuthRepository,
userPreferencesRepository,
} from "@main/repository";
import { HydraApi } from "@main/services"; import { HydraApi } from "@main/services";
const openCheckout = async (_event: Electron.IpcMainInvokeEvent) => { const openCheckout = async (_event: Electron.IpcMainInvokeEvent) => {
const [userAuth, userPreferences] = await Promise.all([ const userAuth = await userAuthRepository.findOne({ where: { id: 1 } });
userAuthRepository.findOne({ where: { id: 1 } }),
userPreferencesRepository.findOne({ where: { id: 1 } }),
]);
if (!userAuth) { if (!userAuth) {
return; return;
@ -22,7 +16,6 @@ const openCheckout = async (_event: Electron.IpcMainInvokeEvent) => {
const params = new URLSearchParams({ const params = new URLSearchParams({
token: paymentToken, token: paymentToken,
lng: userPreferences?.language || "en",
}); });
shell.openExternal( shell.openExternal(

View File

@ -117,11 +117,7 @@ export function GameDetailsContextProvider({
abortControllerRef.current = abortController; abortControllerRef.current = abortController;
window.electron window.electron
.getGameShopDetails( .getGameShopDetails(objectId, shop, getSteamLanguage(i18n.language))
objectId!,
shop as GameShop,
getSteamLanguage(i18n.language)
)
.then((result) => { .then((result) => {
if (abortController.signal.aborted) return; if (abortController.signal.aborted) return;
@ -140,14 +136,14 @@ export function GameDetailsContextProvider({
setIsLoading(false); setIsLoading(false);
}); });
window.electron.getGameStats(objectId, shop as GameShop).then((result) => { window.electron.getGameStats(objectId, shop).then((result) => {
if (abortController.signal.aborted) return; if (abortController.signal.aborted) return;
setStats(result); setStats(result);
}); });
if (userDetails) { if (userDetails) {
window.electron window.electron
.getUnlockedAchievements(objectId, shop as GameShop) .getUnlockedAchievements(objectId, shop)
.then((achievements) => { .then((achievements) => {
if (abortController.signal.aborted) return; if (abortController.signal.aborted) return;
setAchievements(achievements); setAchievements(achievements);