mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-03-09 15:40:26 +00:00
feat: migrating to electron-vite
This commit is contained in:
commit
18de7ca671
183 changed files with 18535 additions and 0 deletions
30
src/main/events/library/get-library.ts
Normal file
30
src/main/events/library/get-library.ts
Normal file
|
@ -0,0 +1,30 @@
|
|||
import { gameRepository } from "@main/repository";
|
||||
import { GameStatus } from "@main/constants";
|
||||
|
||||
import { searchRepacks } from "../helpers/search-games";
|
||||
import { registerEvent } from "../register-event";
|
||||
import { sortBy } from "lodash-es";
|
||||
|
||||
const getLibrary = async (_event: Electron.IpcMainInvokeEvent) =>
|
||||
gameRepository
|
||||
.find({
|
||||
order: {
|
||||
createdAt: "desc",
|
||||
},
|
||||
relations: {
|
||||
repack: true,
|
||||
},
|
||||
})
|
||||
.then((games) =>
|
||||
sortBy(
|
||||
games.map((game) => ({
|
||||
...game,
|
||||
repacks: searchRepacks(game.title),
|
||||
})),
|
||||
(game) => (game.status !== GameStatus.Cancelled ? 0 : 1)
|
||||
)
|
||||
);
|
||||
|
||||
registerEvent(getLibrary, {
|
||||
name: "getLibrary",
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue