marinofaggiana 5 years ago
parent
commit
b74d2c6399

+ 1 - 1
iOSClient/Activity/NCActivity.swift

@@ -228,7 +228,7 @@ extension NCActivity: UITableViewDataSource {
                         let url = self.appDelegate.activeUrl + k_avatar + activity.user + "/128"
                         let encodedString = url.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)
                         OCNetworking.sharedManager()?.downloadContents(ofUrl: encodedString, completion: { (data, message, errorCode) in
-                            if errorCode == 0 {
+                            if errorCode == 0 && UIImage(data: data!) != nil {
                                 do {
                                     try data!.write(to: NSURL(fileURLWithPath: fileNameLocalPath) as URL, options: .atomic)
                                 } catch { return }

+ 1 - 1
iOSClient/Notification/CCNotification.swift

@@ -114,7 +114,7 @@ class CCNotification: UITableViewController, CCNotificationCelllDelegate {
                             let url = self.appDelegate.activeUrl + k_avatar + name + "/128"
                             let encodedString = url.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)
                             OCNetworking.sharedManager()?.downloadContents(ofUrl: encodedString, completion: { (data, message, errorCode) in
-                                if errorCode == 0 && data?.count ?? 0 > 0 {
+                                if errorCode == 0 && UIImage(data: data!) != nil  {
                                     do {
                                         try data!.write(to: NSURL(fileURLWithPath: fileNameLocalPath) as URL, options: .atomic)
                                     } catch { return }

+ 2 - 1
iOSClient/Share/NCShare.swift

@@ -216,7 +216,8 @@ class NCShare: UIViewController, UIGestureRecognizerDelegate, NCShareLinkCellDel
         dropDown.cellNib = UINib(nibName: "NCShareUserDropDownCell", bundle: nil)
         dropDown.customCellConfiguration = { (index: Index, item: String, cell: DropDownCell) -> Void in
             guard let cell = cell as? NCShareUserDropDownCell else { return }
-            NCShareCommon.sharedInstance.downloadAvatar(user: item, cell: cell)
+            let item = items[index]
+            NCShareCommon.sharedInstance.downloadAvatar(user: item.name, cell: cell)
         }
         
         dropDown.selectionAction = { [weak self] (index, item) in

+ 2 - 2
iOSClient/Share/NCShareCommon.swift

@@ -59,7 +59,7 @@ class NCShareCommon: NSObject {
                 let url = appDelegate.activeUrl + k_avatar + user + "/128"
                 let encodedString = url.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)
                 OCNetworking.sharedManager()?.downloadContents(ofUrl: encodedString, completion: { (data, message, errorCode) in
-                    if errorCode == 0 {
+                    if errorCode == 0 && UIImage(data: data!) != nil {
                         do {
                             try data!.write(to: NSURL(fileURLWithPath: fileNameLocalPath) as URL, options: .atomic)
                         } catch { return }
@@ -84,7 +84,7 @@ class NCShareCommon: NSObject {
                 let url = appDelegate.activeUrl + k_avatar + user + "/128"
                 let encodedString = url.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)
                 OCNetworking.sharedManager()?.downloadContents(ofUrl: encodedString, completion: { (data, message, errorCode) in
-                    if errorCode == 0 {
+                    if errorCode == 0 && UIImage(data: data!) != nil {
                         do {
                             try data!.write(to: NSURL(fileURLWithPath: fileNameLocalPath) as URL, options: .atomic)
                         } catch { return }