startLobbyCheck method
void
startLobbyCheck()
Implementation
void startLobbyCheck() {
_timer?.cancel();
_timer = Timer.periodic(const Duration(seconds: 2), (timer) {
final currentTime = DateTime.now().millisecondsSinceEpoch;
// Remove entries older than 12 seconds without `removeWhere`
List<String> toRemove = [];
requestTimestamps.forEach((requestId, timestamp) {
if (currentTime - timestamp > 12000) {
toRemove.add(requestId);
}
});
for (final requestId in toRemove) {
requestTimestamps.remove(requestId);
_previousLobbyRequestList.remove(requestId);
_lobbyRequestList.removeWhere((data) => data.requestId == requestId);
}
startReactionCheck();
if (toRemove.isNotEmpty) {
notifyListeners();
}
});
}