From 4a413db4c560a5fcba331936bfa368b0e2b81f08 Mon Sep 17 00:00:00 2001 From: Zurdi Date: Tue, 2 Jul 2024 17:49:48 +0200 Subject: [PATCH 1/2] fixes from PR review --- backend/exceptions/endpoint_exceptions.py | 8 ++------ backend/handler/database/roms_handler.py | 3 --- frontend/src/components/Details/Saves.vue | 1 - frontend/src/services/api/rom.ts | 2 -- frontend/src/stores/roms.ts | 8 ++++++++ 5 files changed, 10 insertions(+), 12 deletions(-) diff --git a/backend/exceptions/endpoint_exceptions.py b/backend/exceptions/endpoint_exceptions.py index c668b0e96..0de3d09ba 100644 --- a/backend/exceptions/endpoint_exceptions.py +++ b/backend/exceptions/endpoint_exceptions.py @@ -7,9 +7,7 @@ class PlatformNotFoundInDatabaseException(Exception): self.message = f"Platform with id '{id}' not found" super().__init__(self.message) log.critical(self.message) - raise HTTPException( - status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, detail=self.message - ) + raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail=self.message) def __repr__(self) -> str: return self.message @@ -20,9 +18,7 @@ class RomNotFoundInDatabaseException(Exception): self.message = f"Rom with id '{id}' not found" super().__init__(self.message) log.critical(self.message) - raise HTTPException( - status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, detail=self.message - ) + raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail=self.message) def __repr__(self) -> str: return self.message diff --git a/backend/handler/database/roms_handler.py b/backend/handler/database/roms_handler.py index 6c881efaa..998fa714d 100644 --- a/backend/handler/database/roms_handler.py +++ b/backend/handler/database/roms_handler.py @@ -8,9 +8,6 @@ from sqlalchemy.orm import Query, Session, selectinload from .base_handler import DBBaseHandler -class ImplementationError(Exception): ... - - def with_details(func): @functools.wraps(func) def wrapper(*args, **kwargs): diff --git a/frontend/src/components/Details/Saves.vue b/frontend/src/components/Details/Saves.vue index 2b850f7b1..585d326b7 100644 --- a/frontend/src/components/Details/Saves.vue +++ b/frontend/src/components/Details/Saves.vue @@ -13,7 +13,6 @@ const { xs, smAndUp, mdAndUp } = useDisplay(); const props = defineProps<{ rom: DetailedRom }>(); const selectedSaves = ref([]); const emitter = inject>("emitter"); -// emitter?.on("romUpdated", (romUpdated) => {}); const HEADERS = [ { title: "Name", diff --git a/frontend/src/services/api/rom.ts b/frontend/src/services/api/rom.ts index 828e0979d..1bc6aedbd 100644 --- a/frontend/src/services/api/rom.ts +++ b/frontend/src/services/api/rom.ts @@ -142,8 +142,6 @@ async function updateRom({ const formData = new FormData(); if (rom.igdb_id) formData.append("igdb_id", rom.igdb_id.toString()); if (rom.moby_id) formData.append("moby_id", rom.moby_id.toString()); - // if (rom.fav_sibling) - // formData.append("fav_sibling", rom.fav_sibling.toString()); formData.append("name", rom.name || ""); formData.append("file_name", rom.file_name); formData.append("summary", rom.summary || ""); diff --git a/frontend/src/stores/roms.ts b/frontend/src/stores/roms.ts index 2f13ea14b..4906f62b5 100644 --- a/frontend/src/stores/roms.ts +++ b/frontend/src/stores/roms.ts @@ -61,9 +61,17 @@ export default defineStore("roms", { ), ) .map((games) => { + // Find the index of the game where the 'rom_user' property has 'is_main_sibling' set to true. + // If such a game is found, 'mainSiblingIndex' will be its index, otherwise it will be -1. const mainSiblingIndex = games.findIndex( (game) => game.rom_user?.is_main_sibling, ); + + // Determine the primary game: + // - If 'mainSiblingIndex' is not -1 (i.e., a main sibling game was found), + // remove that game from the 'games' array and set it as 'primaryGame'. + // - If no main sibling game was found ('mainSiblingIndex' is -1), + // remove the first game from the 'games' array and set it as 'primaryGame'. const primaryGame = mainSiblingIndex !== -1 ? games.splice(mainSiblingIndex, 1)[0] From 8ef52b87e41fa678e9a4c5f22d8509a86abef96e Mon Sep 17 00:00:00 2001 From: Zurdi <34356590+zurdi15@users.noreply.github.com> Date: Tue, 2 Jul 2024 17:50:14 +0200 Subject: [PATCH 2/2] Update frontend/src/components/Details/Info/FileInfo.vue Co-authored-by: Georges-Antoine Assi <3247106+gantoine@users.noreply.github.com> --- frontend/src/components/Details/Info/FileInfo.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/components/Details/Info/FileInfo.vue b/frontend/src/components/Details/Info/FileInfo.vue index 05cca08ac..ac34f3c49 100644 --- a/frontend/src/components/Details/Info/FileInfo.vue +++ b/frontend/src/components/Details/Info/FileInfo.vue @@ -12,7 +12,7 @@ import { ref, watch } from "vue"; const props = defineProps<{ rom: DetailedRom; platform: Platform }>(); const downloadStore = storeDownload(); const auth = storeAuth(); -const ownProps = ref( +const romUser = ref( props.rom.rom_user ?? { id: null, user_id: auth.user?.id,