فهرست منبع

Merge pull request #1793 from deltachat/handle_ogg_as_file

handle ogg attachments as ordinary files
cyBerta 2 سال پیش
والد
کامیت
3e804edcc1
3فایلهای تغییر یافته به همراه15 افزوده شده و 5 حذف شده
  1. 5 0
      DcCore/DcCore/DC/Wrapper.swift
  2. 9 4
      deltachat-ios/Chat/ChatViewController.swift
  3. 1 1
      deltachat-ios/Chat/Views/FileView.swift

+ 5 - 0
DcCore/DcCore/DC/Wrapper.swift

@@ -1171,6 +1171,11 @@ public class DcMsg {
         return nil
     }
 
+    public var isUnsupportedMediaFile: Bool {
+        let fileMime = filemime
+        return filemime == "audio/ogg"
+    }
+
     public var filename: String? {
         if let cString = dc_msg_get_filename(messagePointer) {
             let str = String(cString: cString)

+ 9 - 4
deltachat-ios/Chat/ChatViewController.swift

@@ -775,10 +775,15 @@ class ChatViewController: UITableViewController, UITableViewDropDelegate {
         case DC_MSG_WEBXDC:
                 cell = tableView.dequeueReusableCell(withIdentifier: "webxdc", for: indexPath) as? WebxdcCell ?? WebxdcCell()
         case DC_MSG_AUDIO, DC_MSG_VOICE:
-            let audioMessageCell: AudioMessageCell = tableView.dequeueReusableCell(withIdentifier: "audio",
-                                                                                      for: indexPath) as? AudioMessageCell ?? AudioMessageCell()
-            audioController.update(audioMessageCell, with: message.id)
-            cell = audioMessageCell
+            if message.isUnsupportedMediaFile {
+                cell = tableView.dequeueReusableCell(withIdentifier: "file", for: indexPath) as? FileTextCell ?? FileTextCell()
+            } else {
+                let audioMessageCell: AudioMessageCell = tableView.dequeueReusableCell(
+                    withIdentifier: "audio",
+                    for: indexPath) as? AudioMessageCell ?? AudioMessageCell()
+                audioController.update(audioMessageCell, with: message.id)
+                cell = audioMessageCell
+            }
         default:
             cell = tableView.dequeueReusableCell(withIdentifier: "text", for: indexPath) as? TextMessageCell ?? TextMessageCell()
         }

+ 1 - 1
deltachat-ios/Chat/Views/FileView.swift

@@ -98,7 +98,7 @@ public class FileView: UIView {
     public func configure(message: DcMsg) {
         if message.type == DC_MSG_WEBXDC {
            configureWebxdc(message: message)
-        } else if message.type == DC_MSG_FILE {
+        } else if message.type == DC_MSG_FILE || message.isUnsupportedMediaFile {
             configureFile(message: message)
         } else {
             logger.error("Configuring message failed")