From 7f16657a845a3936e9133936915b40dc067e6144 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20F=C3=B6rtsch?= Date: Mon, 2 Mar 2026 21:50:33 +0100 Subject: [PATCH] refactor useGame to return { game, loading, reload }, add game detail i18n keys Co-Authored-By: Claude Opus 4.6 --- src/shared/db/hooks.ts | 19 +++++++++++-------- src/shared/i18n/locales/de.ts | 4 ++++ src/shared/i18n/locales/en.ts | 5 +++++ 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/shared/db/hooks.ts b/src/shared/db/hooks.ts index 3e30aaa..969e864 100644 --- a/src/shared/db/hooks.ts +++ b/src/shared/db/hooks.ts @@ -22,17 +22,20 @@ export function useGames() { export function useGame(id: string) { const [game, setGame] = useState(null) + const [loading, setLoading] = useState(true) - useEffect(() => { - async function load() { - const db = await getDb() - const result = await db.query("SELECT * FROM games WHERE id = $1", [id]) - setGame(result.rows[0] ?? null) - } - load() + const reload = useCallback(async () => { + const db = await getDb() + const result = await db.query("SELECT * FROM games WHERE id = $1", [id]) + setGame(result.rows[0] ?? null) + setLoading(false) }, [id]) - return game + useEffect(() => { + reload() + }, [reload]) + + return { game, loading, reload } } export function usePlaylists() { diff --git a/src/shared/i18n/locales/de.ts b/src/shared/i18n/locales/de.ts index 6497d0f..a252d10 100644 --- a/src/shared/i18n/locales/de.ts +++ b/src/shared/i18n/locales/de.ts @@ -61,6 +61,10 @@ export const de: Record = { "settings.syncSaving": "Speichere {current} / {total} Spiele...", "settings.syncSuccess": "{count} Spiele synchronisiert", + "game.lastPlayed": "Zuletzt gespielt", + "game.openStore": "Im Store öffnen", + "game.notFound": "Spiel nicht gefunden.", + "state.not_set": "Nicht gesetzt", "state.wishlisted": "Gewünscht", "state.playlisted": "Eingeplant", diff --git a/src/shared/i18n/locales/en.ts b/src/shared/i18n/locales/en.ts index 4a34671..ee74994 100644 --- a/src/shared/i18n/locales/en.ts +++ b/src/shared/i18n/locales/en.ts @@ -64,6 +64,11 @@ export const en = { "settings.syncSaving": "Saving {current} / {total} games...", "settings.syncSuccess": "Synced {count} games", + // Game detail + "game.lastPlayed": "Last played", + "game.openStore": "Open in Store", + "game.notFound": "Game not found.", + // Game states "state.not_set": "Not Set", "state.wishlisted": "Wishlisted",