🎮 Refactor tournament details handling to use tournamentDetailsState with error management and remove redundant assignments
This commit is contained in:
@@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user