diff --git a/src/main/entity/game.entity.ts b/src/main/entity/game.entity.ts index fedd850e..190e7470 100644 --- a/src/main/entity/game.entity.ts +++ b/src/main/entity/game.entity.ts @@ -6,14 +6,12 @@ import { UpdateDateColumn, OneToOne, JoinColumn, - ManyToMany, } from "typeorm"; import { Repack } from "./repack.entity"; import type { GameShop, GameStatus } from "@types"; import { Downloader } from "@shared"; import type { DownloadQueue } from "./download-queue.entity"; -import { Collection } from "./collection.entity"; @Entity("game") export class Game { @@ -81,9 +79,6 @@ export class Game { @OneToOne("DownloadQueue", "game") downloadQueue: DownloadQueue; - @ManyToMany("Collection", "games") - collections: Collection[]; - @Column("boolean", { default: false }) isDeleted: boolean; diff --git a/src/main/events/collections/get-collections.ts b/src/main/events/collections/get-collections.ts index cf28840d..c8fbd9dd 100644 --- a/src/main/events/collections/get-collections.ts +++ b/src/main/events/collections/get-collections.ts @@ -4,9 +4,11 @@ import { registerEvent } from "../register-event"; const getCollections = async () => collectionRepository.find({ relations: { + games: true, + }, + select: { games: { - downloadQueue: true, - repack: true, + id: true, }, }, order: { diff --git a/src/main/events/library/get-library.ts b/src/main/events/library/get-library.ts index 7f7920bf..ad982308 100644 --- a/src/main/events/library/get-library.ts +++ b/src/main/events/library/get-library.ts @@ -8,7 +8,6 @@ const getLibrary = async () => }, relations: { downloadQueue: true, - collections: true, }, order: { createdAt: "desc", diff --git a/src/renderer/src/components/sidebar/sidebar.tsx b/src/renderer/src/components/sidebar/sidebar.tsx index 337e0351..6a75464c 100644 --- a/src/renderer/src/components/sidebar/sidebar.tsx +++ b/src/renderer/src/components/sidebar/sidebar.tsx @@ -49,11 +49,8 @@ export function Sidebar() { useEffect(() => { updateLibrary(); - }, [lastPacket?.game.id, updateLibrary]); - - useEffect(() => { updateCollections(); - }); + }, [lastPacket?.game.id, updateLibrary, updateCollections]); const isDownloading = sortedLibrary.some( (game) => game.status === "active" && game.progress !== 1 @@ -85,9 +82,16 @@ export function Sidebar() { useEffect(() => { setFilteredLibrary( - sortedLibrary.filter((game) => !game.collections.length) + sortedLibrary.filter( + (game) => + !collections.some((collection) => + collection.games.some( + (collectionGame) => collectionGame.id == game.id + ) + ) + ) ); - }, [sortedLibrary]); + }, [sortedLibrary, collections]); useEffect(() => { window.onmousemove = (event: MouseEvent) => { @@ -216,39 +220,45 @@ export function Sidebar() { ) : null diff --git a/src/types/index.ts b/src/types/index.ts index c5059130..a24e8d26 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -128,7 +128,6 @@ export interface Game { objectID: string; shop: GameShop; downloadQueue: DownloadQueue | null; - collections: Collection[]; createdAt: Date; updatedAt: Date; }