🎮 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) {
if (expandedTournamentId.value === tournamentId) {
expandedTournamentId.value = null;
tournamentDetails.value = null;
tournamentDetailsState.reset();
return;
}
expandedTournamentId.value = tournamentId;
tournamentDetails.value = null;
try {
await tournamentDetailsState.execute(async () => {
if (apiVersion.value === 'v1') {
const result = await client.value.tournaments.get(tournamentId, {
return await client.value.tournaments.get(tournamentId, {
includeParticipants: true,
includeMatches: true
});
tournamentDetails.value = result;
} else {
// v2.1 get tournament
const result = await client.value.tournaments.get(tournamentId);
tournamentDetails.value = result;
return await client.value.tournaments.get(tournamentId);
}
} catch (err) {
handleError(err);
});
// Reset expanded state if there was an error
if (tournamentDetailsState.error.value) {
expandedTournamentId.value = null;
}
}