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:
@@ -22,17 +22,20 @@ export function useGames() {
|
||||
|
||||
export function useGame(id: string) {
|
||||
const [game, setGame] = useState<Game | null>(null)
|
||||
const [loading, setLoading] = useState(true)
|
||||
|
||||
useEffect(() => {
|
||||
async function load() {
|
||||
const db = await getDb()
|
||||
const result = await db.query<Game>("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<Game>("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() {
|
||||
|
||||
@@ -61,6 +61,10 @@ export const de: Record<TranslationKey, string> = {
|
||||
"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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user