mirror of
https://github.com/kuhyx/todo-app.git
synced 2026-11-10 21:07:02 +01:00
429 -> 249 lines:
note_query.dart NoteSort, NoteFilter, and the pure predicates behind
them (matchesFilter, comparatorFor). All of it takes
notes and a filter and returns a decision, which is what
made it the natural seam.
note_import.dart ImportOutcome and the in-memory LogPersistence used by
openInMemory.
note_repository.dart re-exports both, so no call site changed.
Also drops ImportOutcome.total, which nothing called. It was uncovered
before this split too -- the larger file's percentage hid it. With it gone
the suite reports 100% line coverage (2005 lines), up from the 99.9%
baseline measured at the start of this refactor.
lib/ and bin/ are now fully under the cap. 313 tests pass.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
39 lines
1.0 KiB
Dart
39 lines
1.0 KiB
Dart
/// Two small companions of [NoteRepository]: the result of an import, and
|
|
/// the in-memory store its test constructor uses.
|
|
///
|
|
/// Split out of `note_repository.dart` for file size; that file re-exports
|
|
/// this one.
|
|
library;
|
|
|
|
import 'package:crdt_sync/crdt_sync.dart';
|
|
|
|
/// Summary of an [NoteRepository.importNotes] run, for user feedback.
|
|
class ImportOutcome {
|
|
/// Creates an [ImportOutcome] from its per-category counts.
|
|
const ImportOutcome({
|
|
required this.added,
|
|
required this.updated,
|
|
required this.skipped,
|
|
});
|
|
|
|
/// Notes that did not exist locally and were created.
|
|
final int added;
|
|
|
|
/// Existing notes overwritten because the import was newer.
|
|
final int updated;
|
|
|
|
/// Notes skipped because the local copy was the same age or newer.
|
|
final int skipped;
|
|
}
|
|
|
|
/// In-memory [LogPersistence] for [NoteRepository.openInMemory] (tests).
|
|
class MemoryPersistence implements LogPersistence {
|
|
String? _text;
|
|
|
|
@override
|
|
Future<String?> read() async => _text;
|
|
|
|
@override
|
|
Future<void> write(String text) async => _text = text;
|
|
}
|