Store histories and the tile index in SQLite

Message, channel and route histories move from whole-blob preferences to
indexed SQLite rows on native platforms, so chats page from storage instead
of loading a full conversation. Web keeps the preferences store. Existing
histories are imported once on the first launch.

Linux and Windows keep the map tile index in SQLite and import the old JSON
index on first use.

Unreadable legacy data no longer blocks saves, migrations or startup: it is
left in place and skipped. If the database cannot be opened, the run keeps
histories in preferences and the next launch merges them in.

Also adds a performance profiling reference and a script that clears the
Dart HTTP profile.
This commit is contained in:
zjs81 committed 2026-11-09 22:32:40 -07:00
1 parent 0106569e7d
commit 2d56d5e349
47 files changed
+4465 -614

No files matched your search

+5 -4
View File
@@ -15,6 +15,7 @@ class CoalescedWrites {
final Duration delay;
final Map<String, Future<void> Function()> _pending = {};
final Set<Future<void>> _inFlight = {};
Timer? _timer;
bool get hasPending => _pending.isNotEmpty;
@@ -38,20 +39,20 @@ class CoalescedWrites {
Future<void> flush() {
_timer?.cancel();
_timer = null;
if (_pending.isEmpty) return Future<void>.value();
final writes = _pending.values.toList();
_pending.clear();
// Callers fire and forget, so a failed write is logged rather than left
// as an unhandled async error, and never stops the other writes.
final futures = <Future<void>>[];
for (final write in writes) {
try {
futures.add(write().catchError(_logFailure));
final future = write().catchError(_logFailure);
_inFlight.add(future);
unawaited(future.whenComplete(() => _inFlight.remove(future)));
} catch (error) {
_logFailure(error);
}
}
return Future.wait(futures).then((_) {});
return Future.wait(_inFlight.toList()).then((_) {});
}
static void _logFailure(Object error) {