refactor: change game delete to soft delete

This commit is contained in:
JackEnx 2024-04-21 16:36:34 -03:00
parent 8343b66d67
commit 797f5ee0d8
17 changed files with 115 additions and 44 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, {