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:
1 parent
0106569e7d
commit
2d56d5e349
47 files changed
+4465
-614
No files matched your search
@@ -1,3 +1,5 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:meshcore_open/utils/coalesced_writes.dart';
|
||||
|
||||
@@ -63,4 +65,44 @@ void main() {
|
||||
await writes.flush();
|
||||
expect(ran, isTrue);
|
||||
});
|
||||
|
||||
test('flush waits for writes already started by the timer', () async {
|
||||
final writes = CoalescedWrites(delay: Duration.zero);
|
||||
final started = Completer<void>();
|
||||
final persisted = Completer<void>();
|
||||
writes.schedule('history', () {
|
||||
started.complete();
|
||||
return persisted.future;
|
||||
});
|
||||
await started.future;
|
||||
|
||||
var finished = false;
|
||||
final flush = writes.flush().then((_) => finished = true);
|
||||
await _wait(0);
|
||||
expect(finished, isFalse);
|
||||
persisted.complete();
|
||||
await flush;
|
||||
expect(finished, isTrue);
|
||||
});
|
||||
|
||||
test(
|
||||
'a later flush waits for both existing and newly queued writes',
|
||||
() async {
|
||||
final writes = CoalescedWrites();
|
||||
final first = Completer<void>();
|
||||
final second = Completer<void>();
|
||||
writes.schedule('first', () => first.future);
|
||||
final firstFlush = writes.flush();
|
||||
writes.schedule('second', () => second.future);
|
||||
var finished = false;
|
||||
final secondFlush = writes.flush().then((_) => finished = true);
|
||||
|
||||
second.complete();
|
||||
await _wait(0);
|
||||
expect(finished, isFalse);
|
||||
first.complete();
|
||||
await Future.wait([firstFlush, secondFlush]);
|
||||
expect(finished, isTrue);
|
||||
},
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user