chore: merge with main

This commit is contained in:
Hydra
2024-04-25 05:52:19 +01:00
47 changed files with 1337 additions and 451 deletions

View File

@@ -13,15 +13,34 @@ const addGameToLibrary = async (
gameShop: GameShop,
executablePath: string
) => {
const iconUrl = await getImageBase64(await getSteamGameIconUrl(objectID));
return gameRepository.insert({
title,
iconUrl,
objectID,
shop: gameShop,
executablePath,
const game = await gameRepository.findOne({
where: {
objectID,
},
});
if (game) {
return gameRepository.update(
{
id: game.id,
},
{
shop: gameShop,
executablePath,
isDeleted: false,
}
);
} else {
const iconUrl = await getImageBase64(await getSteamGameIconUrl(objectID));
return gameRepository.insert({
title,
iconUrl,
objectID,
shop: gameShop,
executablePath,
});
}
};
registerEvent(addGameToLibrary, {

View File

@@ -22,7 +22,10 @@ const deleteGameFolder = async (
if (!game) return;
if (game.folderName) {
const folderPath = path.join(await getDownloadsPath(), game.folderName);
const folderPath = path.join(
game.downloadPath ?? (await getDownloadsPath()),
game.folderName
);
if (fs.existsSync(folderPath)) {
return new Promise((resolve, reject) => {

View File

@@ -9,6 +9,7 @@ const getGameByObjectID = async (
gameRepository.findOne({
where: {
objectID,
isDeleted: false,
},
relations: {
repack: true,

View File

@@ -5,9 +5,12 @@ import { searchRepacks } from "../helpers/search-games";
import { registerEvent } from "../register-event";
import { sortBy } from "lodash-es";
const getLibrary = async (_event: Electron.IpcMainInvokeEvent) =>
const getLibrary = async () =>
gameRepository
.find({
where: {
isDeleted: false,
},
order: {
createdAt: "desc",
},

View File

@@ -1,7 +1,7 @@
import { registerEvent } from "../register-event";
import { stateManager } from "@main/state-manager";
const getRepackersFriendlyNames = async (_event: Electron.IpcMainInvokeEvent) =>
const getRepackersFriendlyNames = async () =>
stateManager.getValue("repackersFriendlyNames").reduce((prev, next) => {
return { ...prev, [next.name]: next.friendlyName };
}, {});

View File

@@ -23,7 +23,7 @@ const openGameInstaller = async (
);
if (!fs.existsSync(gamePath)) {
await gameRepository.delete({ id: gameId });
await gameRepository.update({ id: gameId }, { status: null });
return true;
}

View File

@@ -0,0 +1,13 @@
import { registerEvent } from "../register-event";
import { gameRepository } from "../../repository";
const removeGameFromLibrary = async (
_event: Electron.IpcMainInvokeEvent,
gameId: number
) => {
gameRepository.update({ id: gameId }, { isDeleted: true });
};
registerEvent(removeGameFromLibrary, {
name: "removeGameFromLibrary",
});