Fix crash if draft attachment lacks data

This commit is contained in:
Shadowfacts 2023-05-16 00:03:54 -04:00
parent 0343e2e310
commit 70f8748364
2 changed files with 8 additions and 1 deletions

View File

@ -112,6 +112,9 @@ class AttachmentThumbnailController: ViewController {
// }
}
}
case .none:
break
}
}

View File

@ -58,7 +58,7 @@ public final class DraftAttachment: NSManagedObject, Identifiable {
} else if let fileURL, let fileType {
return .file(fileURL, UTType(fileType)!)
} else {
fatalError()
return .none
}
}
@ -76,6 +76,7 @@ public final class DraftAttachment: NSManagedObject, Identifiable {
case drawing(PKDrawing)
case file(URL, UTType)
case editing(String, Attachment.Kind, URL)
case none
}
public override func prepareForDeletion() {
@ -246,6 +247,8 @@ extension DraftAttachment {
completion(.success((fileData, type)))
}
}
} else {
completion(.failure(.noData))
}
}
@ -309,5 +312,6 @@ extension DraftAttachment {
case noVideoExportSession
case loadingDrawing
case loadingData
case noData
}
}