feat: add clear logs with confirmation dialog and fix DB dispatchers

- Add clearLogs method to BridgeModule with proper coroutine scope
- Fix fetchLogs and clearLogs using Thread+runBlocking which caused app close
- Change serviceScope from Dispatchers.Main to Dispatchers.IO
- Add error logging in fetchLogs for better diagnostics
- Add clear logs button with confirmation dialog in StatusScreen
This commit is contained in:
fiatcode 2026-05-04 08:38:25 +07:00
parent 1b3440e2fe
commit 60d051ee7b
No known key found for this signature in database
2 changed files with 61 additions and 27 deletions

View file

@ -48,6 +48,45 @@ class _StatusScreenState extends State<StatusScreen> {
}
Future<void> _clearLogs() async {
final confirmed = await showDialog<bool>(
context: context,
builder: (ctx) => AlertDialog(
backgroundColor: const Color(0xFF1e1e1e),
title: const Text(
'Clear Event Logs',
style: TextStyle(fontFamily: 'monospace', color: Color(0xFFe0e0e0)),
),
content: const Text(
'This will permanently delete all logged events. Continue?',
style: TextStyle(fontFamily: 'monospace', color: Color(0xFF9e9e9e)),
),
actions: [
TextButton(
onPressed: () => Navigator.pop(ctx, false),
child: const Text(
'CANCEL',
style: TextStyle(
fontFamily: 'monospace',
color: Color(0xFF616161),
),
),
),
TextButton(
onPressed: () => Navigator.pop(ctx, true),
child: const Text(
'CLEAR',
style: TextStyle(
fontFamily: 'monospace',
color: Color(0xFFff5252),
),
),
),
],
),
);
if (confirmed != true) return;
final result = await LocationBridge.clearLogs();
if (mounted) {
if (result >= 0) {