mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-22 18:33:56 +00:00
Merge branch 'main' into feature/cloud-sync-improvements
This commit is contained in:
@@ -7,7 +7,7 @@ import {
|
||||
gamesPlaytime,
|
||||
} from "@main/services";
|
||||
import { dataSource } from "@main/data-source";
|
||||
import { DownloadQueue, Game, UserAuth } from "@main/entity";
|
||||
import { DownloadQueue, Game, UserAuth, UserSubscription } from "@main/entity";
|
||||
|
||||
const signOut = async (_event: Electron.IpcMainInvokeEvent) => {
|
||||
const databaseOperations = dataSource
|
||||
@@ -19,6 +19,10 @@ const signOut = async (_event: Electron.IpcMainInvokeEvent) => {
|
||||
await transactionalEntityManager
|
||||
.getRepository(UserAuth)
|
||||
.delete({ id: 1 });
|
||||
|
||||
await transactionalEntityManager
|
||||
.getRepository(UserSubscription)
|
||||
.delete({ id: 1 });
|
||||
})
|
||||
.then(() => {
|
||||
/* Removes all games being played */
|
||||
|
||||
@@ -1,43 +1,11 @@
|
||||
import { registerEvent } from "../register-event";
|
||||
import { logger } from "@main/services";
|
||||
import type { ProfileVisibility, UserDetails } from "@types";
|
||||
import { userAuthRepository } from "@main/repository";
|
||||
import { UserNotLoggedInError } from "@shared";
|
||||
import type { UserDetails } from "@types";
|
||||
import { getUserData } from "@main/services/user/get-user-data";
|
||||
|
||||
const getMe = async (
|
||||
_event: Electron.IpcMainInvokeEvent
|
||||
): Promise<UserDetails | null> => {
|
||||
return getUserData().catch(async (err) => {
|
||||
if (err instanceof UserNotLoggedInError) {
|
||||
return null;
|
||||
}
|
||||
logger.error("Failed to get logged user", err);
|
||||
const loggedUser = await userAuthRepository.findOne({ where: { id: 1 } });
|
||||
|
||||
if (loggedUser) {
|
||||
return {
|
||||
...loggedUser,
|
||||
id: loggedUser.userId,
|
||||
username: "",
|
||||
bio: "",
|
||||
profileVisibility: "PUBLIC" as ProfileVisibility,
|
||||
subscription: loggedUser.subscription
|
||||
? {
|
||||
id: loggedUser.subscription.subscriptionId,
|
||||
status: loggedUser.subscription.status,
|
||||
plan: {
|
||||
id: loggedUser.subscription.planId,
|
||||
name: loggedUser.subscription.planName,
|
||||
},
|
||||
expiresAt: loggedUser.subscription.expiresAt,
|
||||
}
|
||||
: null,
|
||||
};
|
||||
}
|
||||
|
||||
return null;
|
||||
});
|
||||
return getUserData();
|
||||
};
|
||||
|
||||
registerEvent("getMe", getMe);
|
||||
|
||||
Reference in New Issue
Block a user