marinofaggiana 3 years ago
parent
commit
e03b8b2b2f

+ 1 - 0
Share/NCShareExtension.swift

@@ -522,6 +522,7 @@ extension NCShareExtension: UICollectionViewDataSource {
         cell.delegate = self
         
         cell.objectId = metadata.ocId
+        cell.user = metadata.ownerId
         cell.labelTitle.text = metadata.fileNameView
         cell.labelTitle.textColor = NCBrandColor.shared.label
         

+ 7 - 0
iOSClient/Activity/NCActivity.swift

@@ -124,6 +124,7 @@ class activityTableViewCell: UITableViewCell, NCCellProtocol {
     var activityPreviews: [tableActivityPreview] = []
     var didSelectItemEnable: Bool = true
     var viewController: UIViewController? = nil
+    var user: String = ""
     
     var fileAvatarImageView: UIImageView? {
         get {
@@ -140,6 +141,11 @@ class activityTableViewCell: UITableViewCell, NCCellProtocol {
             return nil
         }
     }
+    var fileUser: String? {
+        get {
+            return user
+        }
+    }
     
     override func awakeFromNib() {
         super.awakeFromNib()
@@ -243,6 +249,7 @@ extension NCActivity: UITableViewDataSource {
                 
                 cell.subjectTrailingConstraint.constant = 50
                 cell.avatar.isHidden = false
+                cell.user = activity.user
                 
                 let fileNameLocalPath = String(CCUtility.getDirectoryUserData()) + "/" + String(CCUtility.getStringUser(appDelegate.user, urlBase: appDelegate.urlBase)) + "-" + activity.user + ".png"
                 NCOperationQueue.shared.downloadAvatar(user: activity.user, fileNameLocalPath: fileNameLocalPath, placeholder: UIImage(named: "avatar"), cell: cell)

+ 2 - 0
iOSClient/Main/Collection Common/NCCollectionViewCommon.swift

@@ -1423,6 +1423,7 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
             cell.delegate = self
             
             cell.objectId = metadata.ocId
+            cell.user = metadata.ownerId
             cell.labelTitle.text = metadata.fileNameView
             cell.labelTitle.textColor = NCBrandColor.shared.label
             cell.labelInfo.text = ""
@@ -1596,6 +1597,7 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
             cell.delegate = self
             
             cell.objectId = metadata.ocId
+            cell.user = metadata.ownerId
             cell.labelTitle.text = metadata.fileNameView
             cell.labelTitle.textColor = NCBrandColor.shared.label
             

+ 7 - 1
iOSClient/Main/Collection Common/NCGridCell.swift

@@ -38,7 +38,8 @@ class NCGridCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProto
     var delegate: NCGridCellDelegate?
     var objectId = ""
     var namedButtonMore = ""
-    
+    var user = ""
+
     var fileAvatarImageView: UIImageView? {
         get{
             return nil
@@ -54,6 +55,11 @@ class NCGridCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProto
             return imageItem
         }
     }
+    var fileUser: String? {
+        get{
+            return user
+        }
+    }
     
     override func awakeFromNib() {
         super.awakeFromNib()

+ 7 - 1
iOSClient/Main/Collection Common/NCListCell.swift

@@ -44,7 +44,8 @@ class NCListCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProto
     var delegate: NCListCellDelegate?
     var objectId = ""
     var namedButtonMore = ""
-    
+    var user = ""
+
     var fileAvatarImageView: UIImageView? {
         get{
             return imageShared
@@ -60,6 +61,11 @@ class NCListCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProto
             return imageItem
         }
     }
+    var fileUser: String? {
+        get{
+            return user
+        }
+    }
     
     override func awakeFromNib() {
         super.awakeFromNib()

+ 1 - 0
iOSClient/Main/NCCellProtocol.swift

@@ -27,5 +27,6 @@ protocol NCCellProtocol {
     var fileAvatarImageView: UIImageView? { get }
     var fileObjectId: String? { get }
     var filePreviewImageView: UIImageView? { get }
+    var fileUser: String? { get }
 }
 

+ 6 - 0
iOSClient/Media/Cell/NCGridMediaCell.swift

@@ -32,6 +32,7 @@ class NCGridMediaCell: UICollectionViewCell, NCCellProtocol {
     
     var date: Date?
     var objectId: String = ""
+    var user: String = ""
     
     var filePreviewImageView: UIImageView? {
         get {
@@ -48,6 +49,11 @@ class NCGridMediaCell: UICollectionViewCell, NCCellProtocol {
             return objectId
         }
     }
+    var fileUser: String? {
+        get{
+            return user
+        }
+    }
     
     override func awakeFromNib() {
         super.awakeFromNib()

+ 1 - 0
iOSClient/Media/NCMedia.swift

@@ -420,6 +420,7 @@ extension NCMedia: UICollectionViewDataSource {
 
             cell.date = metadata.date as Date
             cell.objectId = metadata.ocId
+            cell.user = metadata.ownerId
 
             if metadata.classFile == NCCommunicationCommon.typeClassFile.video.rawValue || metadata.classFile == NCCommunicationCommon.typeClassFile.audio.rawValue {
                 cell.imageStatus.image = cacheImages.cellPlayImage

+ 1 - 1
iOSClient/Networking/NCOperationQueue.swift

@@ -453,7 +453,7 @@ class NCOperationDownloadAvatar: ConcurrentOperation {
         } else {
             NCCommunication.shared.downloadAvatar(user: user, fileNameLocalPath: fileNameLocalPath, size: NCGlobal.shared.avatarSize) { (account, data, errorCode, errorMessage) in
                 
-                if errorCode == 0 && data != nil {
+                if errorCode == 0 && data != nil  && self.user == self.cell.fileUser {
                    
                     if let avatarImageView = self.cell?.fileAvatarImageView  {
                         

+ 8 - 2
iOSClient/Notification/NCNotification.swift

@@ -131,7 +131,6 @@ class NCNotification: UITableViewController, NCNotificationCellDelegate, NCEmpty
         // Avatar
         cell.avatar.isHidden = true
         cell.avatarLeadingMargin.constant = 10
-
         if let subjectRichParameters = notification.subjectRichParameters {
             if let parameter = JSON(subjectRichParameters).dictionary {
                 if let user = JSON(parameter).dictionary {
@@ -146,6 +145,7 @@ class NCNotification: UITableViewController, NCNotificationCellDelegate, NCEmpty
                         } else {
                             cell.avatar.isHidden = false
                             cell.avatarLeadingMargin.constant = 50
+                            cell.user = userId
                             NCOperationQueue.shared.downloadAvatar(user: userId, fileNameLocalPath: fileNameLocalPath, placeholder: UIImage(named: "avatar"), cell: cell)
                         }
                     }
@@ -332,7 +332,8 @@ class NCNotificationCell: UITableViewCell, NCCellProtocol {
     
     var delegate: NCNotificationCellDelegate?
     var notification: NCCommunicationNotifications?
-
+    var user: String = ""
+    
     var filePreviewImageView : UIImageView? {
         get {
             return nil
@@ -348,6 +349,11 @@ class NCNotificationCell: UITableViewCell, NCCellProtocol {
             return nil
         }
     }
+    var fileUser: String? {
+        get {
+            return user
+        }
+    }
     
     override func awakeFromNib() {
         super.awakeFromNib()

+ 2 - 0
iOSClient/Select/NCSelect.swift

@@ -445,6 +445,7 @@ extension NCSelect: UICollectionViewDataSource {
             cell.delegate = self
             
             cell.objectId = metadata.ocId
+            cell.user = metadata.ownerId
             cell.labelTitle.text = metadata.fileNameView
             cell.labelTitle.textColor = NCBrandColor.shared.label
             
@@ -547,6 +548,7 @@ extension NCSelect: UICollectionViewDataSource {
             cell.delegate = self
             
             cell.objectId = metadata.ocId
+            cell.user = metadata.ownerId
             cell.labelTitle.text = metadata.fileNameView
             cell.labelTitle.textColor = NCBrandColor.shared.label
             

+ 17 - 4
iOSClient/Share/NCShare.swift

@@ -318,6 +318,7 @@ class NCShare: UIViewController, UIGestureRecognizerDelegate, NCShareLinkCellDel
             let status = NCUtility.shared.getUserStatus(userIcon: sharee.userIcon, userStatus: sharee.userStatus, userMessage: sharee.userMessage)
             cell.imageStatus.image = status.onlineStatus
             cell.status.text = status.statusMessage
+            cell.user = sharee.shareWith
             if cell.status.text?.count ?? 0 > 0 {
                 cell.centerTitle.constant = -5
             } else {
@@ -476,6 +477,9 @@ class NCShareUserCell: UITableViewCell, NCCellProtocol {
     @IBOutlet weak var imageStatus: UIImageView!
     @IBOutlet weak var status: UILabel!
     
+    var tableShare: tableShare?
+    var delegate: NCShareUserCellDelegate?
+    
     var fileAvatarImageView: UIImageView? {
         get{
             return imageItem
@@ -491,9 +495,11 @@ class NCShareUserCell: UITableViewCell, NCCellProtocol {
             return nil
         }
     }
-    
-    var tableShare: tableShare?
-    var delegate: NCShareUserCellDelegate?
+    var fileUser: String? {
+        get{
+            return tableShare?.shareWith
+        }
+    }
     
     override func awakeFromNib() {
         super.awakeFromNib()
@@ -527,6 +533,8 @@ class NCShareUserDropDownCell: DropDownCell, NCCellProtocol {
     @IBOutlet weak var imageShareeType: UIImageView!
     @IBOutlet weak var centerTitle: NSLayoutConstraint!
     
+    var user: String = ""
+    
     var fileAvatarImageView: UIImageView? {
         get {
             return imageItem
@@ -537,9 +545,14 @@ class NCShareUserDropDownCell: DropDownCell, NCCellProtocol {
             return nil
         }
     }
-    var filePreviewImageView : UIImageView? {
+    var filePreviewImageView: UIImageView? {
         get {
             return nil
         }
     }
+    var fileUser: String? {
+        get {
+            return user
+        }
+    }
 }

+ 5 - 0
iOSClient/Share/NCShareComments.swift

@@ -233,6 +233,11 @@ class NCShareCommentsCell: UITableViewCell, NCCellProtocol {
             return nil
         }
     }
+    var fileUser: String? {
+        get{
+            return tableComments?.actorId
+        }
+    }
     
     override func awakeFromNib() {
         super.awakeFromNib()

+ 6 - 0
iOSClient/Transfers/NCTransferCell.swift

@@ -38,6 +38,7 @@ class NCTransferCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellP
     
     var delegate: NCTransferCellDelegate?
     var objectId = ""
+    var user = ""
     var indexPath = IndexPath()
     var namedButtonMore = ""
     
@@ -56,6 +57,11 @@ class NCTransferCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellP
             return imageItem
         }
     }
+    var fileUser: String? {
+        get{
+            return user
+        }
+    }
     
     override func awakeFromNib() {
         super.awakeFromNib()

+ 1 - 0
iOSClient/Transfers/NCTransfers.swift

@@ -175,6 +175,7 @@ class NCTransfers: NCCollectionViewCommon, NCTransferCellDelegate  {
         cell.delegate = self
             
         cell.objectId = metadata.ocId
+        cell.user = metadata.ownerId
         cell.indexPath = indexPath
         
         cell.imageItem.image = nil