mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-03-09 15:40:26 +00:00
feat: open checkout page
This commit is contained in:
parent
6ef1135ba2
commit
21fecb2c4e
6 changed files with 32 additions and 8 deletions
|
|
@ -25,6 +25,7 @@ import "./library/verify-executable-path";
|
|||
import "./library/remove-game";
|
||||
import "./library/remove-game-from-library";
|
||||
import "./library/select-game-wine-prefix";
|
||||
import "./misc/open-checkout";
|
||||
import "./misc/open-external";
|
||||
import "./misc/show-open-dialog";
|
||||
import "./torrenting/cancel-game-download";
|
||||
|
|
|
|||
22
src/main/events/misc/open-checkout.ts
Normal file
22
src/main/events/misc/open-checkout.ts
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
import { shell } from "electron";
|
||||
import { registerEvent } from "../register-event";
|
||||
import { userAuthRepository } from "@main/repository";
|
||||
import { HydraApi } from "@main/services";
|
||||
|
||||
const openCheckout = async (_event: Electron.IpcMainInvokeEvent) => {
|
||||
const userAuth = await userAuthRepository.findOne({ where: { id: 1 } });
|
||||
|
||||
if (!userAuth) {
|
||||
return;
|
||||
}
|
||||
|
||||
const paymentToken = await HydraApi.post("/auth/payment", {
|
||||
refreshToken: userAuth.refreshToken,
|
||||
}).then((response) => response.accessToken);
|
||||
|
||||
shell.openExternal(
|
||||
"https://checkout.hydralauncher.gg/?token=" + paymentToken
|
||||
);
|
||||
};
|
||||
|
||||
registerEvent("openCheckout", openCheckout);
|
||||
|
|
@ -119,12 +119,6 @@ export const mergeAchievements = async (
|
|||
const mergedLocalAchievements = unlockedAchievements.concat(newAchievements);
|
||||
|
||||
if (game.remoteId) {
|
||||
achievementsLogger.log(
|
||||
"Syncing achievements with cloud",
|
||||
game.title,
|
||||
game.objectID,
|
||||
game.remoteId
|
||||
);
|
||||
await HydraApi.put(
|
||||
"/profile/games/achievements",
|
||||
{
|
||||
|
|
@ -142,7 +136,7 @@ export const mergeAchievements = async (
|
|||
);
|
||||
})
|
||||
.catch((err) => {
|
||||
if (err! instanceof SubscriptionRequiredError) {
|
||||
if (!(err instanceof SubscriptionRequiredError)) {
|
||||
achievementsLogger.error(err);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue