From 7f646548008607160d51da0355a0857dace54787 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Tue, 16 May 2023 10:57:27 -0400 Subject: [PATCH] Fix crash when adding drawing attachment --- .../ComposeUI/Controllers/AttachmentsListController.swift | 3 +++ .../Sources/ComposeUI/Controllers/ComposeController.swift | 1 + 2 files changed, 4 insertions(+) diff --git a/Packages/ComposeUI/Sources/ComposeUI/Controllers/AttachmentsListController.swift b/Packages/ComposeUI/Sources/ComposeUI/Controllers/AttachmentsListController.swift index 636970e3..15b9b921 100644 --- a/Packages/ComposeUI/Sources/ComposeUI/Controllers/AttachmentsListController.swift +++ b/Packages/ComposeUI/Sources/ComposeUI/Controllers/AttachmentsListController.swift @@ -96,14 +96,17 @@ class AttachmentsListController: ViewController { } private func addImage() { + parent.deleteDraftOnDisappear = false parent.config.presentAssetPicker?({ results in self.insertAttachments(at: self.draft.attachments.count, itemProviders: results.map(\.itemProvider)) }) } private func addDrawing() { + parent.deleteDraftOnDisappear = false parent.config.presentDrawing?(PKDrawing()) { drawing in let attachment = DraftAttachment(context: DraftsPersistentContainer.shared.viewContext) + attachment.id = UUID() attachment.drawing = drawing attachment.draft = self.draft self.draft.attachments.add(attachment) diff --git a/Packages/ComposeUI/Sources/ComposeUI/Controllers/ComposeController.swift b/Packages/ComposeUI/Sources/ComposeUI/Controllers/ComposeController.swift index 84599749..51d55d50 100644 --- a/Packages/ComposeUI/Sources/ComposeUI/Controllers/ComposeController.swift +++ b/Packages/ComposeUI/Sources/ComposeUI/Controllers/ComposeController.swift @@ -208,6 +208,7 @@ public final class ComposeController: ViewController { do { try await poster.post() + deleteDraftOnDisappear = true didPostSuccessfully = true // wait .25 seconds so the user can see the progress bar has completed