Erweiterungen

This commit is contained in:
Sven committed 2026-02-14 08:52:06 +01:00
1 parent ba1f7d5440
commit bb3dc9e856
28 files changed
+1672 -1291

No files matched your search

+23
View File
@@ -9,6 +9,7 @@ import 'package:shared_preferences/shared_preferences.dart';
import 'package:stadtbote/main.dart';
import 'package:stadtbote/model/job.dart';
import 'package:stadtbote/model/log_entry.dart';
import 'package:stadtbote/objectbox.g.dart';
import 'package:stadtbote/tools/constants.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:uuid/uuid.dart';
@@ -97,6 +98,28 @@ class Util {
final box = MyApp.objectBoxStore.box<LogEntry>();
box.put(logEntry);
// Cleanup old logs (delete entries older than 3 days)
_cleanupOldLogs();
}
static void _cleanupOldLogs() async {
try {
final box = MyApp.objectBoxStore.box<LogEntry>();
// Delete logs older than 3 days
final threeDaysAgo = DateTime.now().subtract(const Duration(days: 3));
final oldLogsQuery = box.query(LogEntry_.time.lessThan(threeDaysAgo.millisecondsSinceEpoch)).build();
final oldLogs = oldLogsQuery.find();
oldLogsQuery.close();
if (oldLogs.isNotEmpty) {
box.removeMany(oldLogs.map((e) => e.id).toList());
}
} catch (e) {
// Silent fail for cleanup - don't log to avoid infinite loop
debugPrint('Log cleanup failed: $e');
}
}
static logInfo(String message) {