- Add snoozedUntil and snoozedFromMailboxPath to Emails table. - Implement snoozeEmail and wakeUpEmails in EmailRepository. - Update IMAP and JMAP flush logic to handle snooze/unsnooze. - Update sync logic to parse snz: keywords from server. - Add SnoozePicker widget and integrate into UI. - Add unit tests for Snooze logic.
2.0 KiB
2.0 KiB
Snooze Feature Plan
Goal
Allow users to snooze emails, moving them to a special folder and bringing them back to the Inbox at a specified time. Snooze data must be stored in the account (IMAP/JMAP) for cross-device synchronization.
Technical Approach
1. Metadata Storage (Account Sync)
- Keyword format:
snz:<ISO8601_TIMESTAMP>(e.g.,snz:2026-05-10T15:00:00Z). - JMAP: Use
keywords. - IMAP: Use User Flags (keywords).
2. Database Changes
- Migration v22:
Emailstable:snoozedUntil(DateTime, nullable)snoozedFromMailboxPath(String, nullable) - to remember where to move it back (usually INBOX).
- Index on
snoozedUntil.
3. Repository Updates (EmailRepository)
- New method:
Future<void> snoozeEmail(String emailId, DateTime until)- Optimistically update local DB.
- Enqueue
snoozechange.
- New method:
Future<int> wakeUpEmails(String accountId)- Find local rows where
snoozedUntil <= now. - Enqueue
moveback to original mailbox. - Clear snooze metadata.
- Find local rows where
4. Sync Loop Integration
- In
AccountSyncManager, callwakeUpEmails(accountId)at the start of each sync cycle. - Update IMAP/JMAP sync logic to parse
snz:keywords and update localsnoozedUntil/snoozedFromMailboxPath.
5. UI Implementation
- Snooze Picker: A dialog with options like "Later today", "Tomorrow morning", "Next week", "Custom".
- Action: Add "Snooze" icon to
EmailListScreenselection bar andEmailDetailScreen. - Mailbox: Ensure a "Snoozed" mailbox exists (create if missing).
Implementation Steps
- Database migration and model updates.
- Repository implementation for
snoozeEmailandwakeUpEmails. - Update flush logic for IMAP and JMAP to handle
snoozemutations. - Update sync logic to parse snooze keywords.
- Integrate
wakeUpEmailsinto the sync loop. - UI: Snooze picker dialog.
- UI: Add Snooze action to list and detail screens.
- Testing and validation.