From 8da928e23734467995b8ed4297358ae2cc924acf Mon Sep 17 00:00:00 2001 From: fmodf Date: Tue, 9 Jul 2024 14:43:38 +0200 Subject: [PATCH] wip --- .../AttachmentMediaPickerView.swift | 27 ++++++++----------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/ConversationsClassic/View/Screens/Attachments/AttachmentMediaPickerView.swift b/ConversationsClassic/View/Screens/Attachments/AttachmentMediaPickerView.swift index 3f619fe..7669fec 100644 --- a/ConversationsClassic/View/Screens/Attachments/AttachmentMediaPickerView.swift +++ b/ConversationsClassic/View/Screens/Attachments/AttachmentMediaPickerView.swift @@ -388,23 +388,18 @@ struct CameraPicker: UIViewControllerRepresentable { } func imagePickerController(_: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey: Any]) { - if let mediaType = info[.mediaType] as? UTType { - switch mediaType { - case .image: - if let image = info[.originalImage] as? UIImage { - let data = image.jpegData(compressionQuality: 1.0) ?? Data() - parent.completionHandler(data, .image) - } + // swiftlint:disable:next force_cast + let mediaType = info[.mediaType] as! String - case .movie: - if let url = info[.mediaURL] as? URL { - let data = try? Data(contentsOf: url) - parent.completionHandler(data ?? Data(), .movie) - } - parent.completionHandler(Data(), .movie) - - default: - break + if mediaType == UTType.image.identifier { + if let image = info[.originalImage] as? UIImage { + let data = image.jpegData(compressionQuality: 1.0) ?? Data() + parent.completionHandler(data, .image) + } + } else if mediaType == UTType.movie.identifier { + if let url = info[.mediaURL] as? URL { + let data = try? Data(contentsOf: url) + parent.completionHandler(data ?? Data(), .movie) } } }