fix task store wiring: correct directory path, pass to sync coordinator, remove unused stub

- TaskStore directory changed from `tasks-<id>` to `<accountId>/tasks/` per spec
- TaskStore now created before SyncCoordinator and passed as `taskStore:` arg so deferral resurfacing works
- Use `mailStore.databaseWriter` instead of raw `dbPool` for consistency
- Remove unused `deferSelectedItem` stub (all callers use `deferItem(_:until:)` directly)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-14 09:10:08 +01:00
parent bec9b7eb40
commit 8f63b1c7c1

View File

@@ -121,18 +121,21 @@ final class MailViewModel {
)
}
// Set up TaskStore sharing the same database
let taskDir = FileManager.default.urls(for: .applicationSupportDirectory, in: .userDomainMask)[0]
.appendingPathComponent("MagnumOpus", isDirectory: true)
.appendingPathComponent(config.id, isDirectory: true)
.appendingPathComponent("tasks", isDirectory: true)
let ts = TaskStore(taskDirectory: taskDir, dbWriter: mailStore.databaseWriter)
taskStore = ts
coordinator = SyncCoordinator(
accountConfig: config,
imapClient: imapClient,
store: mailStore,
actionQueue: queue
actionQueue: queue,
taskStore: ts
)
// Set up TaskStore sharing the same database
let taskDir = FileManager.default.urls(for: .applicationSupportDirectory, in: .userDomainMask)[0]
.appendingPathComponent("MagnumOpus", isDirectory: true)
.appendingPathComponent("tasks-\(config.id)", isDirectory: true)
taskStore = TaskStore(taskDirectory: taskDir, dbWriter: dbPool)
}
func loadMailboxes(accountId: String) async {
@@ -467,13 +470,6 @@ final class MailViewModel {
// MARK: - GTD Triage Actions (unified items)
func deferSelectedItem(until date: Date?) {
guard let store, let accountConfig else { return }
// Find the currently selected item from the items list
// We use the selected thread for emails, or need context for tasks
// For now, work with the first selected item concept
}
func deferItem(_ item: ItemSummary, until date: Date?) {
guard let store, let accountConfig else { return }
do {