Fixed state bug
This commit is contained in:
@@ -145,7 +145,11 @@ class _HomeViewState extends State<HomeView> {
|
|||||||
MatchResultView(match: match),
|
MatchResultView(match: match),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
await updatedWinnerInRecentMatches(match.id);
|
await loadRecentMatches();
|
||||||
|
|
||||||
|
setState(() {
|
||||||
|
print('loaded');
|
||||||
|
});
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
@@ -244,17 +248,12 @@ class _HomeViewState extends State<HomeView> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Updates the winner information for a specific match in the recent matches list.
|
Future<void> loadRecentMatches() async {
|
||||||
Future<void> updatedWinnerInRecentMatches(String matchId) async {
|
|
||||||
final db = Provider.of<AppDatabase>(context, listen: false);
|
final db = Provider.of<AppDatabase>(context, listen: false);
|
||||||
// TODO: fix
|
final matches = await db.matchDao.getAllMatches();
|
||||||
//final winner = await db.scoreEntryDao.getWinner(matchId: matchId);
|
recentMatches =
|
||||||
final matchIndex = recentMatches.indexWhere((match) => match.id == matchId);
|
(matches..sort((a, b) => b.createdAt.compareTo(a.createdAt)))
|
||||||
if (matchIndex != -1) {
|
.take(2)
|
||||||
setState(() {
|
.toList();
|
||||||
// TODO: fix
|
|
||||||
//recentMatches[matchIndex].winner = winner;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user