New method for specific winner refreshing
This commit is contained in:
@@ -111,7 +111,7 @@ class _HomeViewState extends State<HomeView> {
|
|||||||
MatchResultView(match: match),
|
MatchResultView(match: match),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
loadHomeViewData();
|
await updatedWinnerinRecentMatches(match.id);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
@@ -186,7 +186,7 @@ class _HomeViewState extends State<HomeView> {
|
|||||||
|
|
||||||
/// Loads the data for the HomeView from the database.
|
/// Loads the data for the HomeView from the database.
|
||||||
/// This includes the match count, group count, and recent matches.
|
/// This includes the match count, group count, and recent matches.
|
||||||
void loadHomeViewData() {
|
Future<void> loadHomeViewData() async {
|
||||||
final db = Provider.of<AppDatabase>(context, listen: false);
|
final db = Provider.of<AppDatabase>(context, listen: false);
|
||||||
Future.wait([
|
Future.wait([
|
||||||
db.matchDao.getMatchCount(),
|
db.matchDao.getMatchCount(),
|
||||||
@@ -209,4 +209,18 @@ class _HomeViewState extends State<HomeView> {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Updates the winner information for a specific match in the recent matches list.
|
||||||
|
Future<void> updatedWinnerinRecentMatches(String matchId) async {
|
||||||
|
final db = Provider.of<AppDatabase>(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;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
name: game_tracker
|
name: game_tracker
|
||||||
description: "Game Tracking App for Card Games"
|
description: "Game Tracking App for Card Games"
|
||||||
publish_to: 'none'
|
publish_to: 'none'
|
||||||
version: 0.0.3+92
|
version: 0.0.3+93
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ^3.8.1
|
sdk: ^3.8.1
|
||||||
|
|||||||
Reference in New Issue
Block a user