Эх сурвалжийг харах

fix replacing attachments in drafts

cyberta 3 жил өмнө
parent
commit
b6fb344e18

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

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