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

Update NCCommunication lib

Signed-off-by: marinofaggiana <marino@marinofaggiana.com>
marinofaggiana 3 жил өмнө
parent
commit
6da13e5c38

+ 1 - 1
Nextcloud.xcodeproj/project.pbxproj

@@ -2939,7 +2939,7 @@
 			repositoryURL = "https://github.com/nextcloud/ios-communication-library/";
 			repositoryURL = "https://github.com/nextcloud/ios-communication-library/";
 			requirement = {
 			requirement = {
 				kind = revision;
 				kind = revision;
-				revision = 5d9391aa2034f97ca9a9bd6fda29f46caea2f720;
+				revision = 434fce0a92b6ee6cc3f798d29e043cc9d48d2d6c;
 			};
 			};
 		};
 		};
 		F788ECC5263AAAF900ADC67F /* XCRemoteSwiftPackageReference "MarkdownKit" */ = {
 		F788ECC5263AAAF900ADC67F /* XCRemoteSwiftPackageReference "MarkdownKit" */ = {

+ 1 - 1
Nextcloud.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved

@@ -105,7 +105,7 @@
         "repositoryURL": "https://github.com/nextcloud/ios-communication-library/",
         "repositoryURL": "https://github.com/nextcloud/ios-communication-library/",
         "state": {
         "state": {
           "branch": null,
           "branch": null,
-          "revision": "5d9391aa2034f97ca9a9bd6fda29f46caea2f720",
+          "revision": "434fce0a92b6ee6cc3f798d29e043cc9d48d2d6c",
           "version": null
           "version": null
         }
         }
       },
       },

+ 4 - 0
iOSClient/NCGlobal.swift

@@ -100,6 +100,10 @@ class NCGlobal: NSObject {
     let refreshTask                                 = "com.nextcloud.refreshTask"
     let refreshTask                                 = "com.nextcloud.refreshTask"
     let processingTask                              = "com.nextcloud.processingTask"
     let processingTask                              = "com.nextcloud.processingTask"
     
     
+    // Queue in background for NCCommunication
+    //
+    let backgroundQueue                             = DispatchQueue(label: "com.nextcloud.nccommunication", qos: .background, attributes: .concurrent)
+
     // Nextcloud version
     // Nextcloud version
     //
     //
     let nextcloudVersion12: Int                     =  12
     let nextcloudVersion12: Int                     =  12

+ 36 - 32
iOSClient/Networking/NCOperationQueue.swift

@@ -421,26 +421,28 @@ class NCOperationDownloadThumbnail: ConcurrentOperation {
             if FileManager.default.fileExists(atPath: fileNameIconLocalPath) && FileManager.default.fileExists(atPath: fileNamePreviewLocalPath) {
             if FileManager.default.fileExists(atPath: fileNameIconLocalPath) && FileManager.default.fileExists(atPath: fileNamePreviewLocalPath) {
                 etagResource = metadata.etagResource
                 etagResource = metadata.etagResource
             }
             }
-            NCCommunication.shared.downloadPreview(fileNamePathOrFileId: fileNamePath, fileNamePreviewLocalPath: fileNamePreviewLocalPath , widthPreview: NCGlobal.shared.sizePreview, heightPreview: NCGlobal.shared.sizePreview, fileNameIconLocalPath: fileNameIconLocalPath, sizeIcon: NCGlobal.shared.sizeIcon, etag: etagResource) { (account, imagePreview, imageIcon, imageOriginal, etag, errorCode, errorDescription) in
+            NCCommunication.shared.downloadPreview(fileNamePathOrFileId: fileNamePath, fileNamePreviewLocalPath: fileNamePreviewLocalPath , widthPreview: NCGlobal.shared.sizePreview, heightPreview: NCGlobal.shared.sizePreview, fileNameIconLocalPath: fileNameIconLocalPath, sizeIcon: NCGlobal.shared.sizeIcon, etag: etagResource, queue: NCGlobal.shared.backgroundQueue) { (account, imagePreview, imageIcon, imageOriginal, etag, errorCode, errorDescription) in
                 
                 
                 if errorCode == 0 && imageIcon != nil {
                 if errorCode == 0 && imageIcon != nil {
                     NCManageDatabase.shared.setMetadataEtagResource(ocId: self.metadata.ocId, etagResource: etag)
                     NCManageDatabase.shared.setMetadataEtagResource(ocId: self.metadata.ocId, etagResource: etag)
-                    if self.metadata.ocId == self.cell?.fileObjectId {
-                        if let filePreviewImageView = self.cell?.filePreviewImageView  {
-                            UIView.transition(with: filePreviewImageView,
-                                duration: 0.75,
-                                options: .transitionCrossDissolve,
-                                animations: { filePreviewImageView.image = imageIcon! },
-                                completion: nil)
-                        }
-                    } else {
-                        if self.view is UICollectionView {
-                            (self.view as? UICollectionView)?.reloadData()
-                        } else if self.view is UITableView{
-                            (self.view as? UITableView)?.reloadData()
+                    DispatchQueue.main.async {
+                        if self.metadata.ocId == self.cell?.fileObjectId {
+                            if let filePreviewImageView = self.cell?.filePreviewImageView  {
+                                UIView.transition(with: filePreviewImageView,
+                                    duration: 0.75,
+                                    options: .transitionCrossDissolve,
+                                    animations: { filePreviewImageView.image = imageIcon! },
+                                    completion: nil)
+                            }
+                        } else {
+                            if self.view is UICollectionView {
+                                (self.view as? UICollectionView)?.reloadData()
+                            } else if self.view is UITableView{
+                                (self.view as? UITableView)?.reloadData()
+                            }
                         }
                         }
+                        NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterDownloadedThumbnail, userInfo: ["ocId": self.metadata.ocId])
                     }
                     }
-                    NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterDownloadedThumbnail, userInfo: ["ocId": self.metadata.ocId])
                 }
                 }
                 self.finish()
                 self.finish()
             }
             }
@@ -474,29 +476,31 @@ class NCOperationDownloadAvatar: ConcurrentOperation {
         if isCancelled {
         if isCancelled {
             self.finish()
             self.finish()
         } else {
         } else {
-            NCCommunication.shared.downloadAvatar(user: user, fileNameLocalPath: fileNameLocalPath, sizeImage: NCGlobal.shared.avatarSize, avatarSizeRounded: NCGlobal.shared.avatarSizeRounded, etag: self.etag) { (account, imageAvatar, imageOriginal, etag, errorCode, errorMessage) in
+            NCCommunication.shared.downloadAvatar(user: user, fileNameLocalPath: fileNameLocalPath, sizeImage: NCGlobal.shared.avatarSize, avatarSizeRounded: NCGlobal.shared.avatarSizeRounded, etag: self.etag, queue: NCGlobal.shared.backgroundQueue) { (account, imageAvatar, imageOriginal, etag, errorCode, errorMessage) in
                 
                 
                 if errorCode == 0, let imageAvatar = imageAvatar, let etag = etag {
                 if errorCode == 0, let imageAvatar = imageAvatar, let etag = etag {
                     
                     
                     NCManageDatabase.shared.addAvatar(fileName: self.fileName, etag: etag)
                     NCManageDatabase.shared.addAvatar(fileName: self.fileName, etag: etag)
-                    
-                    if self.user == self.cell.fileUser {
-                        if let avatarImageView = self.cell?.fileAvatarImageView  {
-                            UIView.transition(with: avatarImageView, duration: 0.75, options: .transitionCrossDissolve) {
-                                avatarImageView.image = imageAvatar
-                            } completion: { _ in
-                                if self.view is UICollectionView {
-                                    (self.view as? UICollectionView)?.reloadData()
-                                } else if self.view is UITableView{
-                                    (self.view as? UITableView)?.reloadData()
+
+                    DispatchQueue.main.async {
+                        if self.user == self.cell.fileUser {
+                            if let avatarImageView = self.cell?.fileAvatarImageView  {
+                                UIView.transition(with: avatarImageView, duration: 0.75, options: .transitionCrossDissolve) {
+                                    avatarImageView.image = imageAvatar
+                                } completion: { _ in
+                                    if self.view is UICollectionView {
+                                        (self.view as? UICollectionView)?.reloadData()
+                                    } else if self.view is UITableView{
+                                        (self.view as? UITableView)?.reloadData()
+                                    }
                                 }
                                 }
                             }
                             }
-                        }
-                    } else {
-                        if self.view is UICollectionView {
-                            (self.view as? UICollectionView)?.reloadData()
-                        } else if self.view is UITableView{
-                            (self.view as? UITableView)?.reloadData()
+                        } else {
+                            if self.view is UICollectionView {
+                                (self.view as? UICollectionView)?.reloadData()
+                            } else if self.view is UITableView{
+                                (self.view as? UITableView)?.reloadData()
+                            }
                         }
                         }
                     }
                     }
                     
                     

+ 1 - 1
iOSClient/Networking/NCService.swift

@@ -111,7 +111,7 @@ class NCService: NSObject {
                     let fileNameLocalPath = String(CCUtility.getDirectoryUserData()) + "/" + fileName
                     let fileNameLocalPath = String(CCUtility.getDirectoryUserData()) + "/" + fileName
                     let etag = NCManageDatabase.shared.getTableAvatar(fileName: fileName)?.etag
                     let etag = NCManageDatabase.shared.getTableAvatar(fileName: fileName)?.etag
 
 
-                    NCCommunication.shared.downloadAvatar(user: tableAccount.userId, fileNameLocalPath: fileNameLocalPath, sizeImage: NCGlobal.shared.avatarSize, avatarSizeRounded: NCGlobal.shared.avatarSizeRounded, etag: etag) { (account, image, imageOriginal, etag, errorCode, errorMessage) in
+                    NCCommunication.shared.downloadAvatar(user: tableAccount.userId, fileNameLocalPath: fileNameLocalPath, sizeImage: NCGlobal.shared.avatarSize, avatarSizeRounded: NCGlobal.shared.avatarSizeRounded, etag: etag, queue: NCGlobal.shared.backgroundQueue) { (account, image, imageOriginal, etag, errorCode, errorMessage) in
 
 
                         if let etag = etag, errorCode == 0, let imageOriginal = imageOriginal {
                         if let etag = etag, errorCode == 0, let imageOriginal = imageOriginal {