diff --git a/lib/presentation/views/main_menu/home_view.dart b/lib/presentation/views/main_menu/home_view.dart index f59831c..1b07839 100644 --- a/lib/presentation/views/main_menu/home_view.dart +++ b/lib/presentation/views/main_menu/home_view.dart @@ -111,7 +111,7 @@ class _HomeViewState extends State { MatchResultView(match: match), ), ); - loadHomeViewData(); + await updatedWinnerinRecentMatches(match.id); }, ), ) @@ -186,7 +186,7 @@ class _HomeViewState extends State { /// Loads the data for the HomeView from the database. /// This includes the match count, group count, and recent matches. - void loadHomeViewData() { + Future loadHomeViewData() async { final db = Provider.of(context, listen: false); Future.wait([ db.matchDao.getMatchCount(), @@ -209,4 +209,18 @@ class _HomeViewState extends State { } }); } + + /// Updates the winner information for a specific match in the recent matches list. + Future updatedWinnerinRecentMatches(String matchId) async { + final db = Provider.of(context, listen: false); + final winner = await db.matchDao.getWinner(matchId: matchId); + print('Winner for match $matchId: ${winner?.name}'); + + final matchIndex = recentMatches.indexWhere((match) => match.id == matchId); + if (matchIndex != -1) { + setState(() { + recentMatches[matchIndex].winner = winner; + }); + } + } } diff --git a/pubspec.yaml b/pubspec.yaml index b6f2ed3..7ace12f 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: game_tracker description: "Game Tracking App for Card Games" publish_to: 'none' -version: 0.0.3+92 +version: 0.0.3+93 environment: sdk: ^3.8.1