Updated addGameSessionMethod
This commit is contained in:
@@ -11,14 +11,14 @@ class GameManager extends ChangeNotifier {
|
|||||||
/// sorts the list in descending order based on the creation date, and notifies listeners of the change.
|
/// sorts the list in descending order based on the creation date, and notifies listeners of the change.
|
||||||
/// It also saves the updated game sessions to local storage.
|
/// It also saves the updated game sessions to local storage.
|
||||||
/// Returns the index of the newly added session in the sorted list.
|
/// Returns the index of the newly added session in the sorted list.
|
||||||
Future<int> addGameSession(GameSession session) async {
|
int addGameSession(GameSession session) {
|
||||||
session.addListener(() {
|
session.addListener(() {
|
||||||
notifyListeners(); // Propagate session changes
|
notifyListeners(); // Propagate session changes
|
||||||
});
|
});
|
||||||
gameList.add(session);
|
gameList.add(session);
|
||||||
gameList.sort((a, b) => b.createdAt.compareTo(a.createdAt));
|
gameList.sort((a, b) => b.createdAt.compareTo(a.createdAt));
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
await LocalStorageService.saveGameSessions();
|
LocalStorageService.saveGameSessions();
|
||||||
return gameList.indexOf(session);
|
return gameList.indexOf(session);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user