refactor useGame to return { game, loading, reload }, add game detail i18n keys

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-02 21:50:33 +01:00
parent 7337f38710
commit 7f16657a84
3 changed files with 20 additions and 8 deletions

View File

@@ -22,17 +22,20 @@ export function useGames() {
export function useGame(id: string) { export function useGame(id: string) {
const [game, setGame] = useState<Game | null>(null) const [game, setGame] = useState<Game | null>(null)
const [loading, setLoading] = useState(true)
useEffect(() => { const reload = useCallback(async () => {
async function load() { const db = await getDb()
const db = await getDb() const result = await db.query<Game>("SELECT * FROM games WHERE id = $1", [id])
const result = await db.query<Game>("SELECT * FROM games WHERE id = $1", [id]) setGame(result.rows[0] ?? null)
setGame(result.rows[0] ?? null) setLoading(false)
}
load()
}, [id]) }, [id])
return game useEffect(() => {
reload()
}, [reload])
return { game, loading, reload }
} }
export function usePlaylists() { export function usePlaylists() {

View File

@@ -61,6 +61,10 @@ export const de: Record<TranslationKey, string> = {
"settings.syncSaving": "Speichere {current} / {total} Spiele...", "settings.syncSaving": "Speichere {current} / {total} Spiele...",
"settings.syncSuccess": "{count} Spiele synchronisiert", "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.not_set": "Nicht gesetzt",
"state.wishlisted": "Gewünscht", "state.wishlisted": "Gewünscht",
"state.playlisted": "Eingeplant", "state.playlisted": "Eingeplant",

View File

@@ -64,6 +64,11 @@ export const en = {
"settings.syncSaving": "Saving {current} / {total} games...", "settings.syncSaving": "Saving {current} / {total} games...",
"settings.syncSuccess": "Synced {count} games", "settings.syncSuccess": "Synced {count} games",
// Game detail
"game.lastPlayed": "Last played",
"game.openStore": "Open in Store",
"game.notFound": "Game not found.",
// Game states // Game states
"state.not_set": "Not Set", "state.not_set": "Not Set",
"state.wishlisted": "Wishlisted", "state.wishlisted": "Wishlisted",