Fix crash when compose screen dismissed while adding attachments
This commit is contained in:
parent
3ecee61013
commit
42e29862ac
|
@ -85,8 +85,11 @@ class AttachmentsListController: ViewController {
|
||||||
for provider in itemProviders where provider.canLoadObject(ofClass: DraftAttachment.self) {
|
for provider in itemProviders where provider.canLoadObject(ofClass: DraftAttachment.self) {
|
||||||
provider.loadObject(ofClass: DraftAttachment.self) { object, error in
|
provider.loadObject(ofClass: DraftAttachment.self) { object, error in
|
||||||
guard let attachment = object as? DraftAttachment else { return }
|
guard let attachment = object as? DraftAttachment else { return }
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async { [weak self] in
|
||||||
guard self.canAddAttachment else { return }
|
guard let self,
|
||||||
|
self.canAddAttachment else {
|
||||||
|
return
|
||||||
|
}
|
||||||
DraftsPersistentContainer.shared.viewContext.insert(attachment)
|
DraftsPersistentContainer.shared.viewContext.insert(attachment)
|
||||||
attachment.draft = self.draft
|
attachment.draft = self.draft
|
||||||
self.draft.attachments.add(attachment)
|
self.draft.attachments.add(attachment)
|
||||||
|
|
Loading…
Reference in New Issue