浏览代码

fix replacing attachments in drafts

cyberta 3 年之前
父节点
当前提交
b6fb344e18
共有 1 个文件被更改,包括 3 次插入5 次删除
  1. 3 5
      deltachat-ios/Chat/DraftModel.swift

+ 3 - 5
deltachat-ios/Chat/DraftModel.swift

@@ -45,19 +45,17 @@ public class DraftModel {
     }
 
     public func setAttachment(viewType: Int32?, path: String?, mimetype: String? = nil) {
-        if draftMsg == nil {
-            draftMsg = dcContext.newMessage(viewType: viewType ?? DC_MSG_TEXT)
-        }
+        let quoteMsg = draftMsg?.quoteMessage
+        draftMsg = dcContext.newMessage(viewType: viewType ?? DC_MSG_TEXT)
+        draftMsg?.quoteMessage = quoteMsg
         draftMsg?.setFile(filepath: path, mimeType: mimetype)
         save(context: dcContext)
     }
 
     public func clearAttachment() {
-        let text = draftMsg?.text
         let quoteMsg = draftMsg?.quoteMessage
         if text != nil || quoteMsg != nil {
             draftMsg = dcContext.newMessage(viewType: DC_MSG_TEXT)
-            draftMsg?.text = text
             draftMsg?.quoteMessage = quoteMsg
             save(context: dcContext)
         } else {