From b2de57e4ef36afeaaede4528d9e3cebc088250fb Mon Sep 17 00:00:00 2001 From: FragginWagon Date: Thu, 29 Jan 2026 02:03:18 +0000 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Refactor=20tournament=20listing=20l?= =?UTF-8?q?ogic=20to=20use=20state=20management=20and=20simplify=20error?= =?UTF-8?q?=20handling?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pokedex.online/src/views/ChallongeTest.vue | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/code/websites/pokedex.online/src/views/ChallongeTest.vue b/code/websites/pokedex.online/src/views/ChallongeTest.vue index 54d4105..d157379 100644 --- a/code/websites/pokedex.online/src/views/ChallongeTest.vue +++ b/code/websites/pokedex.online/src/views/ChallongeTest.vue @@ -564,24 +564,20 @@ function getTournamentProp(tournament, prop) { } async function testListTournaments(resetPagination = true) { - loading.value = true; - error.value = null; - if (resetPagination) { currentPage.value = 1; - tournaments.value = null; searchQuery.value = ''; expandedTournamentId.value = null; - tournamentDetails.value = null; + tournamentDetailsState.reset(); } - try { + await tournamentListState.execute(async () => { if (apiVersion.value === 'v1') { // v1 doesn't support pagination const result = await client.value.tournaments.list(); - tournaments.value = result; totalTournaments.value = result.length; hasNextPage.value = false; + return result; } else { // v2.1 - Query all tournament states (pending, in_progress, ended) in parallel // USER scope returns tournaments you have access to: @@ -622,15 +618,11 @@ async function testListTournaments(resetPagination = true) { results: result }); - tournaments.value = result; totalTournaments.value = result.length; hasNextPage.value = result.length >= 100; + return result; } - } catch (err) { - handleError(err); - } finally { - loading.value = false; - } + }); } async function loadMoreTournaments() {