mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-03-09 15:40:26 +00:00
refactor: change game delete to soft delete
This commit is contained in:
parent
8343b66d67
commit
797f5ee0d8
17 changed files with 115 additions and 44 deletions
|
@ -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, {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue