feat(U2): sync local drafts with IMAP Drafts folder #27

Merged
guettlibot merged 1 commits from task/u2-draft-sync into main 2026-05-13 22:27:48 +00:00
guettlibot commented 2026-05-13 22:24:17 +00:00 (Migrated from codeberg.org)

Implements bidirectional draft synchronisation between the local SQLite database and the server's IMAP Drafts folder.

Changes

  • Schema v24: adds imap_server_id nullable text column to drafts table; migration is guarded with from >= 4 to avoid a duplicate-column error when creating the table fresh (since m.createTable uses the latest schema)
  • SavedDraft model: adds imapServerId field
  • DraftRepository interface: adds syncDrafts(accountId, password)
  • DraftRepositoryImpl: accepts AccountRepository and optional ImapConnectFn; implements syncDrafts — creates/selects the Drafts IMAP folder, uploads local-only drafts via APPEND (stores returned UID), downloads server drafts not yet tracked locally
  • AccountSyncManager: accepts optional DraftRepository?; passes it to _AccountSync which calls syncDrafts at the start of each sync cycle
  • DI: draftRepositoryProvider now passes account repo + IMAP connect factory; syncManagerProvider wires in the draft repo
  • Tests: added syncDrafts stub to FakeDraftRepository; updated draft_repository_impl_test.dart constructor calls; added _StubAccounts helper
Implements bidirectional draft synchronisation between the local SQLite database and the server's IMAP Drafts folder. ## Changes - **Schema v24**: adds `imap_server_id` nullable text column to `drafts` table; migration is guarded with `from >= 4` to avoid a duplicate-column error when creating the table fresh (since `m.createTable` uses the latest schema) - **`SavedDraft` model**: adds `imapServerId` field - **`DraftRepository` interface**: adds `syncDrafts(accountId, password)` - **`DraftRepositoryImpl`**: accepts `AccountRepository` and optional `ImapConnectFn`; implements `syncDrafts` — creates/selects the Drafts IMAP folder, uploads local-only drafts via APPEND (stores returned UID), downloads server drafts not yet tracked locally - **`AccountSyncManager`**: accepts optional `DraftRepository?`; passes it to `_AccountSync` which calls `syncDrafts` at the start of each sync cycle - **DI**: `draftRepositoryProvider` now passes account repo + IMAP connect factory; `syncManagerProvider` wires in the draft repo - **Tests**: added `syncDrafts` stub to `FakeDraftRepository`; updated `draft_repository_impl_test.dart` constructor calls; added `_StubAccounts` helper
Sign in to join this conversation.