From bbdb7fe41f38fa136aa055cb5959fb00263765e7 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Thu, 4 May 2023 10:11:04 -0400 Subject: [PATCH] Fix crash on deleting draft with attachments in share extension --- .../Sources/ComposeUI/Controllers/ComposeController.swift | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Packages/ComposeUI/Sources/ComposeUI/Controllers/ComposeController.swift b/Packages/ComposeUI/Sources/ComposeUI/Controllers/ComposeController.swift index 17ae478b..5aea5cf9 100644 --- a/Packages/ComposeUI/Sources/ComposeUI/Controllers/ComposeController.swift +++ b/Packages/ComposeUI/Sources/ComposeUI/Controllers/ComposeController.swift @@ -154,7 +154,7 @@ public final class ComposeController: ViewController { if draft.hasContent { isShowingSaveDraftSheet = true } else { - DraftsPersistentContainer.shared.viewContext.delete(draft) + deleteDraftOnDisappear = true config.dismiss(.cancel) } } @@ -162,9 +162,7 @@ public final class ComposeController: ViewController { @MainActor func cancel(deleteDraft: Bool) { - if deleteDraft { - DraftsPersistentContainer.shared.viewContext.delete(draft) - } + deleteDraftOnDisappear = true config.dismiss(.cancel) }