Skip to content

Commit

Permalink
fix: issues
Browse files Browse the repository at this point in the history
  • Loading branch information
zamitto committed Dec 31, 2024
1 parent cbbe699 commit ad204e3
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 17 deletions.
2 changes: 2 additions & 0 deletions src/main/events/auth/get-session-hash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ const getSessionHash = async (_event: Electron.IpcMainInvokeEvent) => {
if (!auth) return null;
const payload = jwt.decode(auth.accessToken) as jwt.JwtPayload;

if (!payload) return null;

return payload.sessionId;
};

Expand Down
6 changes: 5 additions & 1 deletion src/main/events/cloud-save/get-game-artifacts.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { HydraApi } from "@main/services";
import { registerEvent } from "../register-event";
import type { GameArtifact, GameShop } from "@types";
import { SubscriptionRequiredError } from "@shared";
import { SubscriptionRequiredError, UserNotLoggedInError } from "@shared";

const getGameArtifacts = async (
_event: Electron.IpcMainInvokeEvent,
Expand All @@ -22,6 +22,10 @@ const getGameArtifacts = async (
return [];
}

if (err instanceof UserNotLoggedInError) {
return [];
}

throw err;
});
};
Expand Down
11 changes: 2 additions & 9 deletions src/main/events/misc/open-checkout.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
import { shell } from "electron";
import { registerEvent } from "../register-event";
import {
userAuthRepository,
userPreferencesRepository,
} from "@main/repository";
import { userAuthRepository } from "@main/repository";
import { HydraApi } from "@main/services";

const openCheckout = async (_event: Electron.IpcMainInvokeEvent) => {
const [userAuth, userPreferences] = await Promise.all([
userAuthRepository.findOne({ where: { id: 1 } }),
userPreferencesRepository.findOne({ where: { id: 1 } }),
]);
const userAuth = await userAuthRepository.findOne({ where: { id: 1 } });

if (!userAuth) {
return;
Expand All @@ -22,7 +16,6 @@ const openCheckout = async (_event: Electron.IpcMainInvokeEvent) => {

const params = new URLSearchParams({
token: paymentToken,
lng: userPreferences?.language || "en",
});

shell.openExternal(
Expand Down
10 changes: 3 additions & 7 deletions src/renderer/src/context/game-details/game-details.context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,7 @@ export function GameDetailsContextProvider({
abortControllerRef.current = abortController;

window.electron
.getGameShopDetails(
objectId!,
shop as GameShop,
getSteamLanguage(i18n.language)
)
.getGameShopDetails(objectId, shop, getSteamLanguage(i18n.language))
.then((result) => {
if (abortController.signal.aborted) return;

Expand All @@ -140,14 +136,14 @@ export function GameDetailsContextProvider({
setIsLoading(false);
});

window.electron.getGameStats(objectId, shop as GameShop).then((result) => {
window.electron.getGameStats(objectId, shop).then((result) => {
if (abortController.signal.aborted) return;
setStats(result);
});

if (userDetails) {
window.electron
.getUnlockedAchievements(objectId, shop as GameShop)
.getUnlockedAchievements(objectId, shop)
.then((achievements) => {
if (abortController.signal.aborted) return;
setAchievements(achievements);
Expand Down

0 comments on commit ad204e3

Please sign in to comment.