From b4b598d1f5a5689e2c99642a3745bcfed819ac2a Mon Sep 17 00:00:00 2001 From: Felix Kirchner Date: Tue, 21 Apr 2026 22:22:35 +0200 Subject: [PATCH] Fixed state bug --- .../views/main_menu/home_view.dart | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/lib/presentation/views/main_menu/home_view.dart b/lib/presentation/views/main_menu/home_view.dart index 888acf8..321f12b 100644 --- a/lib/presentation/views/main_menu/home_view.dart +++ b/lib/presentation/views/main_menu/home_view.dart @@ -145,7 +145,11 @@ class _HomeViewState extends State { MatchResultView(match: match), ), ); - await updatedWinnerInRecentMatches(match.id); + await loadRecentMatches(); + + setState(() { + print('loaded'); + }); }, ), ) @@ -244,17 +248,12 @@ class _HomeViewState extends State { }); } - /// Updates the winner information for a specific match in the recent matches list. - Future updatedWinnerInRecentMatches(String matchId) async { + Future loadRecentMatches() async { final db = Provider.of(context, listen: false); - // TODO: fix - //final winner = await db.scoreEntryDao.getWinner(matchId: matchId); - final matchIndex = recentMatches.indexWhere((match) => match.id == matchId); - if (matchIndex != -1) { - setState(() { - // TODO: fix - //recentMatches[matchIndex].winner = winner; - }); - } + final matches = await db.matchDao.getAllMatches(); + recentMatches = + (matches..sort((a, b) => b.createdAt.compareTo(a.createdAt))) + .take(2) + .toList(); } }