🎮 Refactor tournament details handling to use tournamentDetailsState with error management and remove redundant assignments

This commit is contained in:
2026-01-29 02:03:33 +00:00
parent 1f85443db9
commit 6835e3a7b8

View File

@@ -658,27 +658,26 @@ async function changePerPage(newLimit) {
async function toggleTournamentDetails(tournamentId) { async function toggleTournamentDetails(tournamentId) {
if (expandedTournamentId.value === tournamentId) { if (expandedTournamentId.value === tournamentId) {
expandedTournamentId.value = null; expandedTournamentId.value = null;
tournamentDetails.value = null; tournamentDetailsState.reset();
return; return;
} }
expandedTournamentId.value = tournamentId; expandedTournamentId.value = tournamentId;
tournamentDetails.value = null;
try { await tournamentDetailsState.execute(async () => {
if (apiVersion.value === 'v1') { if (apiVersion.value === 'v1') {
const result = await client.value.tournaments.get(tournamentId, { return await client.value.tournaments.get(tournamentId, {
includeParticipants: true, includeParticipants: true,
includeMatches: true includeMatches: true
}); });
tournamentDetails.value = result;
} else { } else {
// v2.1 get tournament // v2.1 get tournament
const result = await client.value.tournaments.get(tournamentId); return await client.value.tournaments.get(tournamentId);
tournamentDetails.value = result;
} }
} catch (err) { });
handleError(err);
// Reset expanded state if there was an error
if (tournamentDetailsState.error.value) {
expandedTournamentId.value = null; expandedTournamentId.value = null;
} }
} }