From 524c0168ee916fef3a4108520c74fab2d4ac03a8 Mon Sep 17 00:00:00 2001 From: Julien <120588494+julien4215@users.noreply.github.com> Date: Tue, 10 Dec 2024 17:01:42 +0100 Subject: [PATCH] Remove forgotten sorting logic that was left in the provider --- .../model/broadcast/broadcast_providers.dart | 48 +++---------------- 1 file changed, 7 insertions(+), 41 deletions(-) diff --git a/lib/src/model/broadcast/broadcast_providers.dart b/lib/src/model/broadcast/broadcast_providers.dart index b782ae7081..a7e02edc8d 100644 --- a/lib/src/model/broadcast/broadcast_providers.dart +++ b/lib/src/model/broadcast/broadcast_providers.dart @@ -55,48 +55,14 @@ Future broadcastTournament( ); } -enum BroadcastPlayersSortingTypes { player, elo, score } - @riverpod -class BroadcastPlayers extends _$BroadcastPlayers { - @override - Future> build( - BroadcastTournamentId tournamentId, - ) async { - final players = ref.withClient( - (client) => BroadcastRepository(client).getPlayers(tournamentId), - ); - - return players; - } - - void sort(BroadcastPlayersSortingTypes sortingType, [bool reverse = false]) { - if (!state.hasValue) return; - - final compare = switch (sortingType) { - BroadcastPlayersSortingTypes.player => - (BroadcastPlayerExtended a, BroadcastPlayerExtended b) => - a.name.compareTo(b.name), - BroadcastPlayersSortingTypes.elo => - (BroadcastPlayerExtended a, BroadcastPlayerExtended b) { - if (a.rating == null) return -1; - if (b.rating == null) return 1; - return b.rating!.compareTo(a.rating!); - }, - BroadcastPlayersSortingTypes.score => - (BroadcastPlayerExtended a, BroadcastPlayerExtended b) { - if (a.score == null) return -1; - if (b.score == null) return 1; - return b.score!.compareTo(a.score!); - } - }; - - state = AsyncData( - reverse - ? state.requireValue.sortReversed(compare) - : state.requireValue.sort(compare), - ); - } +Future> broadcastPlayers( + Ref ref, + BroadcastTournamentId tournamentId, +) { + return ref.withClient( + (client) => BroadcastRepository(client).getPlayers(tournamentId), + ); } @Riverpod(keepAlive: true)