Преглед изворни кода

Merge pull request #1269 from deltachat/fix_share_text

fixing sharing text
cyBerta пре 4 година
родитељ
комит
119a3fa1de
2 измењених фајлова са 10 додато и 2 уклоњено
  1. 8 2
      DcShare/Controller/ShareViewController.swift
  2. 2 0
      DcShare/Helper/ShareAttachment.swift

+ 8 - 2
DcShare/Controller/ShareViewController.swift

@@ -41,7 +41,7 @@ class ShareViewController: SLComposeServiceViewController {
     var selectedChat: DcChat?
     var shareAttachment: ShareAttachment?
     var isAccountConfigured: Bool = true
-    var isLoading: Bool = true
+    var isLoading: Bool = false
 
     var previewImageHeightConstraint: NSLayoutConstraint?
     var previewImageWidthConstraint: NSLayoutConstraint?
@@ -94,7 +94,8 @@ class ShareViewController: SLComposeServiceViewController {
                 if let chatId = selectedChatId {
                     selectedChat = dcContext.getChat(chatId: chatId)
                 }
-                DispatchQueue.global(qos: .userInitiated).async {
+                DispatchQueue.global(qos: .userInitiated).async { [weak self] in
+                    guard let self = self else { return }
                     self.shareAttachment = ShareAttachment(dcContext: self.dcContext, inputItems: self.extensionContext?.inputItems, delegate: self)
                 }
             }
@@ -236,7 +237,12 @@ extension ShareViewController: ShareAttachmentDelegate {
         }
     }
 
+    func onLoadingStarted() {
+        isLoading = true
+    }
+
     func onLoadingFinished() {
         isLoading = false
+        self.validateContent()
     }
 }

+ 2 - 0
DcShare/Helper/ShareAttachment.swift

@@ -9,6 +9,7 @@ protocol ShareAttachmentDelegate: class {
     func onAttachmentChanged()
     func onThumbnailChanged()
     func onUrlShared(url: URL)
+    func onLoadingStarted()
     func onLoadingFinished()
 }
 
@@ -42,6 +43,7 @@ class ShareAttachment {
 
     private func createMessages() {
         guard let items = inputItems as? [NSExtensionItem] else { return }
+        delegate?.onLoadingStarted()
         for item in items {
             if let attachments = item.attachments {
                 createMessageFromDataRepresentation(attachments)