mirror of
https://github.com/kodjodevf/mangayomi.git
synced 2026-03-11 17:25:32 +00:00
add log buffer and replace direct list mutation
- Introduce _addLog() helper to manage log insertion - Enforce a maximum log history of 200 entries to prevent unbounded memory growth - Replace direct _logsNotifier.value.add(event) with safe, immutable-style list update - Improve log handling consistency and avoid mutating notifier state in place
This commit is contained in:
parent
09684a2641
commit
f4f344ce29
1 changed files with 13 additions and 1 deletions
|
|
@ -93,7 +93,7 @@ class _CodeEditorPageState extends ConsumerState<CodeEditorPage> {
|
|||
_controller.text = source?.sourceCode ?? "";
|
||||
useLogger = true;
|
||||
_logSubscription = _logStreamController.stream.listen((event) async {
|
||||
_logsNotifier.value.add(event);
|
||||
_addLog(event);
|
||||
try {
|
||||
await Future.delayed(const Duration(milliseconds: 5));
|
||||
if (_scrollController.hasClients) {
|
||||
|
|
@ -103,6 +103,18 @@ class _CodeEditorPageState extends ConsumerState<CodeEditorPage> {
|
|||
});
|
||||
}
|
||||
|
||||
static const int _maxLogs = 200;
|
||||
|
||||
void _addLog((LoggerLevel, String, DateTime) log) {
|
||||
final logs = _logsNotifier.value;
|
||||
final newLogs = List<(LoggerLevel, String, DateTime)>.from(logs);
|
||||
if (newLogs.length >= _maxLogs) {
|
||||
newLogs.removeAt(0);
|
||||
}
|
||||
newLogs.add(log);
|
||||
_logsNotifier.value = newLogs;
|
||||
}
|
||||
|
||||
List<dynamic> filters = [];
|
||||
|
||||
Future<String?> filterDialog(BuildContext context) async {
|
||||
|
|
|
|||
Loading…
Reference in a new issue