feat: draft auto-save in compose screen
- Add Drafts table (schema v4 migration) with autoincrement id, accountId, replyToEmailId, to/cc/subject/body text, updatedAt - DraftRepository interface + DraftRepositoryImpl (Drift) - draftRepositoryProvider wired in di.dart - ComposeScreen debounces saves (2 s after last keystroke), shows transient "Saved" indicator, restores the latest matching draft on open when no prefill fields are provided, deletes draft on send - 6 new unit tests for DraftRepositoryImpl - New widget test verifying draft restore behaviour - FakeDraftRepository added to widget test helpers - draft_repository.dart added to coverage no-code exclusion list Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
2f1924be9c
commit
e1e95e97ee
@@ -80,14 +80,27 @@ class EmailBodies extends Table {
|
||||
Set<Column> get primaryKey => {emailId};
|
||||
}
|
||||
|
||||
/// Auto-saved compose drafts — persisted across app restarts.
|
||||
class Drafts extends Table {
|
||||
IntColumn get id => integer().autoIncrement()();
|
||||
TextColumn get accountId => text().nullable()();
|
||||
/// Set for replies/reply-alls; null for new messages.
|
||||
TextColumn get replyToEmailId => text().nullable()();
|
||||
TextColumn get toText => text().withDefault(const Constant(''))();
|
||||
TextColumn get ccText => text().withDefault(const Constant(''))();
|
||||
TextColumn get subjectText => text().withDefault(const Constant(''))();
|
||||
TextColumn get bodyText => text().withDefault(const Constant(''))();
|
||||
DateTimeColumn get updatedAt => dateTime()();
|
||||
}
|
||||
|
||||
// ── Database ──────────────────────────────────────────────────────────────────
|
||||
|
||||
@DriftDatabase(tables: [Accounts, Mailboxes, Emails, EmailBodies])
|
||||
@DriftDatabase(tables: [Accounts, Mailboxes, Emails, EmailBodies, Drafts])
|
||||
class AppDatabase extends _$AppDatabase {
|
||||
AppDatabase([QueryExecutor? executor]) : super(executor ?? _openConnection());
|
||||
|
||||
@override
|
||||
int get schemaVersion => 3;
|
||||
int get schemaVersion => 4;
|
||||
|
||||
@override
|
||||
MigrationStrategy get migration => MigrationStrategy(
|
||||
@@ -99,6 +112,9 @@ class AppDatabase extends _$AppDatabase {
|
||||
if (from < 3) {
|
||||
await m.addColumn(accounts, accounts.username);
|
||||
}
|
||||
if (from < 4) {
|
||||
await m.createTable(drafts);
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user