marinofaggiana 3 years ago
parent
commit
976902c7ef

+ 1 - 1
Nextcloud.xcodeproj/project.pbxproj

@@ -2939,7 +2939,7 @@
 			repositoryURL = "https://github.com/nextcloud/ios-communication-library/";
 			requirement = {
 				kind = revision;
-				revision = 19e9266a5bb47453dd9568cf13f84883d27d4a49;
+				revision = 8d036cc622596e3b5bd6d61d5c0448cfb336e294;
 			};
 		};
 		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/",
         "state": {
           "branch": null,
-          "revision": "19e9266a5bb47453dd9568cf13f84883d27d4a49",
+          "revision": "8d036cc622596e3b5bd6d61d5c0448cfb336e294",
           "version": null
         }
       },

+ 1 - 6
Share/NCShareExtension.swift

@@ -241,7 +241,7 @@ class NCShareExtension: UIViewController, NCListCellDelegate, NCEmptyDataSetDele
         // PROFILE BUTTON
                 
         var image = NCUtility.shared.loadImage(named: "person.crop.circle")
-        let fileNamePath = String(CCUtility.getDirectoryUserData()) + "/" + String(CCUtility.getStringUser(activeAccount.user, urlBase: activeAccount.urlBase)) + "-" + activeAccount.user + ".png"
+        let fileNamePath = String(CCUtility.getDirectoryUserData()) + "/" + String(CCUtility.getUserUrlBase(activeAccount.user, urlBase: activeAccount.urlBase)) + "-" + activeAccount.user + ".png"
         if let userImage = UIImage(contentsOfFile: fileNamePath) {
             image = userImage
         }
@@ -582,11 +582,6 @@ extension NCShareExtension: UICollectionViewDataSource {
         } else {
             cell.imageShared.image = NCBrandColor.cacheImages.canShare
         }
-        if metadata.ownerId.count > 0 && metadata.ownerId != activeAccount.userId {
-            let userUrlBase = String(CCUtility.getStringUser(activeAccount.user, urlBase: activeAccount.urlBase))
-            let fileNameLocalPath = String(CCUtility.getDirectoryUserData()) + "/" + userUrlBase + "-" + metadata.ownerId + ".png"
-            NCOperationQueue.shared.downloadAvatar(user: metadata.ownerId, userUrlBase: userUrlBase, fileNameLocalPath: fileNameLocalPath, placeholder: nil, cell: cell, view: collectionView)
-        }
         
         cell.imageSelect.isHidden = true
         cell.backgroundView = nil

+ 1 - 1
iOSClient/Activity/NCActivity.swift

@@ -254,7 +254,7 @@ extension NCActivity: UITableViewDataSource {
                 cell.avatar.isHidden = false
                 cell.fileUser = activity.user
                 
-                let userUrlBase = String(CCUtility.getStringUser(appDelegate.user, urlBase: appDelegate.urlBase))
+                let userUrlBase = String(CCUtility.getUserUrlBase(appDelegate.user, urlBase: appDelegate.urlBase))
                 let fileNameLocalPath = String(CCUtility.getDirectoryUserData()) + "/" + userUrlBase + "-" + activity.user + ".png"
                 NCOperationQueue.shared.downloadAvatar(user: activity.user, userUrlBase: userUrlBase, fileNameLocalPath: fileNameLocalPath, placeholder: UIImage(named: "avatar"), cell: cell, view: tableView)
             }

+ 1 - 1
iOSClient/Data/NCDatabase.swift

@@ -482,7 +482,7 @@ class tableUser: Object {
     @objc dynamic var etag = ""
     @objc dynamic var user = ""
     @objc dynamic var userUrlBase = ""
-    
+
     override static func primaryKey() -> String {
         return "userUrlBase"
     }

+ 3 - 3
iOSClient/Data/NCManageDatabase.swift

@@ -116,7 +116,7 @@ class NCManageDatabase: NSObject {
                         }
                     }
                     
-                    if oldSchemaVersion < 196 {
+                    if oldSchemaVersion < 199 {
                         migration.deleteData(forType: tableDirectory.className())
                         migration.deleteData(forType: tableE2eEncryption.className())
                         migration.deleteData(forType: tableE2eEncryptionLock.className())
@@ -2977,7 +2977,7 @@ class NCManageDatabase: NSObject {
                 addObject.etag = etag
                 addObject.user = user
                 addObject.userUrlBase = userUrlBase
-    
+
                 realm.add(addObject, update: .all)
             }
         } catch let error {
@@ -2985,7 +2985,7 @@ class NCManageDatabase: NSObject {
         }
     }
     
-    @objc func getUser(userUrlBase: String) -> tableUser? {
+    @objc func getTableUser(userUrlBase: String) -> tableUser? {
         
         let realm = try! Realm()
         

+ 1 - 1
iOSClient/Main/Account Request/NCAccountRequest.swift

@@ -238,7 +238,7 @@ extension NCAccountRequest: UITableViewDataSource {
 
             avatarImage?.image = NCUtility.shared.loadImage(named: "person.crop.circle")
         
-            let fileNamePath = String(CCUtility.getDirectoryUserData()) + "/" + String(CCUtility.getStringUser(account.user, urlBase: account.urlBase)) + "-" + account.user + ".png"
+            let fileNamePath = String(CCUtility.getDirectoryUserData()) + "/" + String(CCUtility.getUserUrlBase(account.user, urlBase: account.urlBase)) + "-" + account.user + ".png"
             
             if let image = UIImage(contentsOfFile: fileNamePath) {
                 avatarImage?.image = NCUtility.shared.createAvatar(image: image, size: 40)

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

@@ -625,7 +625,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
             if layoutKey == NCGlobal.shared.layoutViewFiles {
             
                 var image = NCUtility.shared.loadImage(named: "person.crop.circle")
-                let fileNamePath = String(CCUtility.getDirectoryUserData()) + "/" + String(CCUtility.getStringUser(appDelegate.user, urlBase: appDelegate.urlBase)) + "-" + appDelegate.user + ".png"
+                let fileNamePath = String(CCUtility.getDirectoryUserData()) + "/" + String(CCUtility.getUserUrlBase(appDelegate.user, urlBase: appDelegate.urlBase)) + "-" + appDelegate.user + ".png"
                 if let userImage = UIImage(contentsOfFile: fileNamePath) {
                     image = userImage
                 }
@@ -1372,7 +1372,7 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
         
         // Avatar
         if metadata.ownerId.count > 0 && metadata.ownerId != appDelegate.userId && appDelegate.account == metadata.account {
-            let userUrlBase = String(CCUtility.getStringUser(metadata.user, urlBase: metadata.urlBase))
+            let userUrlBase = String(CCUtility.getUserUrlBase(metadata.user, urlBase: metadata.urlBase))
             let fileNameLocalPath = String(CCUtility.getDirectoryUserData()) + "/" + userUrlBase + "-" + metadata.ownerId + ".png"
             NCOperationQueue.shared.downloadAvatar(user: metadata.ownerId, userUrlBase: userUrlBase, fileNameLocalPath: fileNameLocalPath, placeholder: NCBrandColor.cacheImages.shared, cell: cell, view: collectionView)
         }

+ 1 - 1
iOSClient/Menu/NCLoginWeb+Menu.swift

@@ -37,7 +37,7 @@ extension NCLoginWeb {
         for account in accounts {
             
             let title = account.user + " " + (URL(string: account.urlBase)?.host ?? "")
-            let fileNamePath = String(CCUtility.getDirectoryUserData()) + "/" + String(CCUtility.getStringUser(account.user, urlBase: account.urlBase)) + "-" + account.user + ".png"
+            let fileNamePath = String(CCUtility.getDirectoryUserData()) + "/" + String(CCUtility.getUserUrlBase(account.user, urlBase: account.urlBase)) + "-" + account.user + ".png"
 
             if let image = UIImage(contentsOfFile: fileNamePath) {
                 avatar = NCUtility.shared.createAvatar(image: image, size: 50)

+ 1 - 1
iOSClient/More/NCMore.swift

@@ -323,7 +323,7 @@ class NCMore: UIViewController, UITableViewDelegate, UITableViewDataSource {
             cell.status.text = ""
             cell.displayName.text = ""
             
-            let fileNamePath = String(CCUtility.getDirectoryUserData()) + "/" + String(CCUtility.getStringUser(appDelegate.user, urlBase: appDelegate.urlBase)) + "-" + appDelegate.user + ".png"
+            let fileNamePath = String(CCUtility.getDirectoryUserData()) + "/" + String(CCUtility.getUserUrlBase(appDelegate.user, urlBase: appDelegate.urlBase)) + "-" + appDelegate.user + ".png"
             
             if let image = UIImage.init(contentsOfFile: fileNamePath) {
                 cell.avatar?.image = NCUtility.shared.createAvatar(image: image, size: 50)

+ 1 - 1
iOSClient/NCGlobal.swift

@@ -79,7 +79,7 @@ class NCGlobal: NSObject {
     // Database Realm
     //
     let databaseDefault                             = "nextcloud.realm"
-    let databaseSchemaVersion: UInt64               = 197
+    let databaseSchemaVersion: UInt64               = 199
     
     // Intro selector
     //

+ 2 - 1
iOSClient/Networking/NCOperationQueue.swift

@@ -444,6 +444,7 @@ class NCOperationDownloadAvatar: ConcurrentOperation {
     var user: String
     var userUrlBase: String
     var etag: String?
+    var userFile: String = ""
     var fileNameLocalPath: String
     var cell: NCCellProtocol!
     var view: UIView?
@@ -454,7 +455,7 @@ class NCOperationDownloadAvatar: ConcurrentOperation {
         self.fileNameLocalPath = fileNameLocalPath
         self.cell = cell
         self.view = view
-        etag = NCManageDatabase.shared.getUser(userUrlBase: userUrlBase)?.etag
+        self.etag = NCManageDatabase.shared.getTableUser(userUrlBase: userUrlBase)?.etag
     }
     
     override func start() {

+ 2 - 2
iOSClient/Networking/NCService.swift

@@ -96,7 +96,7 @@ class NCService: NSObject {
                 
                     let user = tableAccount.user
                     let url = tableAccount.urlBase
-                    let stringUser = CCUtility.getStringUser(user, urlBase: url)!
+                    let userUrlBase = CCUtility.getUserUrlBase(user, urlBase: url)!
                     
                     self.appDelegate.settingAccount(tableAccount.account, urlBase: tableAccount.urlBase, user: tableAccount.user, userId: tableAccount.userId, password: CCUtility.getPassword(tableAccount.account))
                        
@@ -107,7 +107,7 @@ class NCService: NSObject {
                     self.synchronizeOffline(account: tableAccount.account)
                     
                     // Get Avatar
-                    let fileNameLocalPath = String(CCUtility.getDirectoryUserData()) + "/" + stringUser + "-" + self.appDelegate.user + ".png"
+                    let fileNameLocalPath = String(CCUtility.getDirectoryUserData()) + "/" + userUrlBase + "-" + self.appDelegate.user + ".png"
                     let oldData = try? Data(contentsOf: URL(fileURLWithPath: fileNameLocalPath))
                     NCCommunication.shared.downloadAvatar(user: user, fileNameLocalPath: fileNameLocalPath, size: NCGlobal.shared.avatarSize, etag: nil) { (account, data, etag, errorCode, errorMessage) in
                         if let data = data, let oldData = oldData {

+ 1 - 1
iOSClient/Notification/NCNotification.swift

@@ -136,7 +136,7 @@ class NCNotification: UITableViewController, NCNotificationCellDelegate, NCEmpty
             if let parameter = JSON(subjectRichParameters).dictionary {
                 if let user = JSON(parameter).dictionary {
                     if let userId = user["id"]?.string {
-                        let userUrlBase = String(CCUtility.getStringUser(appDelegate.user, urlBase: appDelegate.urlBase))
+                        let userUrlBase = String(CCUtility.getUserUrlBase(appDelegate.user, urlBase: appDelegate.urlBase))
                         let fileNameLocalPath = String(CCUtility.getDirectoryUserData()) + "/" + userUrlBase + "-" + userId + ".png"
                         if FileManager.default.fileExists(atPath: fileNameLocalPath) {
                             if let image = UIImage(contentsOfFile: fileNameLocalPath) {

+ 1 - 1
iOSClient/Select/NCSelect.swift

@@ -416,7 +416,7 @@ extension NCSelect: UICollectionViewDataSource {
         
         // Avatar
         if metadata.ownerId.count > 0 && metadata.ownerId != activeAccount.userId && activeAccount.account == metadata.account {
-            let userUrlBase = String(CCUtility.getStringUser(metadata.user, urlBase: metadata.urlBase))
+            let userUrlBase = String(CCUtility.getUserUrlBase(metadata.user, urlBase: metadata.urlBase))
             let fileNameLocalPath = String(CCUtility.getDirectoryUserData()) + "/" + userUrlBase + "-" + metadata.ownerId + ".png"
             NCOperationQueue.shared.downloadAvatar(user: metadata.ownerId, userUrlBase: userUrlBase, fileNameLocalPath: fileNameLocalPath, placeholder: NCBrandColor.cacheImages.shared, cell: cell, view: collectionView)
         }

+ 1 - 1
iOSClient/Settings/CCManageAccount.m

@@ -56,7 +56,7 @@
         row = [XLFormRowDescriptor formRowDescriptorWithTag:account.account rowType:XLFormRowDescriptorTypeBooleanCheck title:title];
         
         // Avatar
-        NSString *fileNamePath = [NSString stringWithFormat:@"%@/%@-%@.png", [CCUtility getDirectoryUserData], [CCUtility getStringUser:account.user urlBase:account.urlBase], account.user];
+        NSString *fileNamePath = [NSString stringWithFormat:@"%@/%@-%@.png", [CCUtility getDirectoryUserData], [CCUtility getUserUrlBase:account.user urlBase:account.urlBase], account.user];
         UIImage *avatar = [UIImage imageWithContentsOfFile:fileNamePath];
         if (avatar) {
             avatar = [[NCUtility shared] createAvatarWithImage:avatar size:40];

+ 3 - 3
iOSClient/Share/NCShare.swift

@@ -96,7 +96,7 @@ class NCShare: UIViewController, UIGestureRecognizerDelegate, NCShareLinkCellDel
             sharedWithYouByLabel.text = NSLocalizedString("_shared_with_you_by_", comment: "") + " " + metadata!.ownerDisplayName
             sharedWithYouByImage.image = UIImage(named: "avatar")?.imageColor(NCBrandColor.shared.label)
 
-            let fileNameLocalPath = String(CCUtility.getDirectoryUserData()) + "/" + String(CCUtility.getStringUser(appDelegate.user, urlBase: appDelegate.urlBase)) + "-" + metadata!.ownerId + ".png"
+            let fileNameLocalPath = String(CCUtility.getDirectoryUserData()) + "/" + String(CCUtility.getUserUrlBase(appDelegate.user, urlBase: appDelegate.urlBase)) + "-" + metadata!.ownerId + ".png"
             if FileManager.default.fileExists(atPath: fileNameLocalPath) {
                 if let image = UIImage(contentsOfFile: fileNameLocalPath) {
                     sharedWithYouByImage.image = NCUtility.shared.createAvatar(image: image, size: 40)
@@ -333,7 +333,7 @@ class NCShare: UIViewController, UIGestureRecognizerDelegate, NCShareLinkCellDel
             } else {
                 cell.centerTitle.constant = 0
             }
-            let userUrlBase = String(CCUtility.getStringUser(self.appDelegate.user, urlBase: self.appDelegate.urlBase))
+            let userUrlBase = String(CCUtility.getUserUrlBase(self.appDelegate.user, urlBase: self.appDelegate.urlBase))
             let fileNameLocalPath = String(CCUtility.getDirectoryUserData()) + "/" + userUrlBase + "-" + sharee.label + ".png"
             NCOperationQueue.shared.downloadAvatar(user: sharee.shareWith, userUrlBase: userUrlBase, fileNameLocalPath: fileNameLocalPath, placeholder: UIImage(named: "avatar"), cell: cell, view: nil)
             cell.imageShareeType.image = NCShareCommon.shared.getImageShareType(shareType: sharee.shareType)
@@ -412,7 +412,7 @@ extension NCShare: UITableViewDataSource {
                 cell.imageStatus.image = status.onlineStatus
                 cell.status.text = status.statusMessage
                 
-                let userUrlBase = String(CCUtility.getStringUser(appDelegate.user, urlBase: appDelegate.urlBase))
+                let userUrlBase = String(CCUtility.getUserUrlBase(appDelegate.user, urlBase: appDelegate.urlBase))
                 let fileNameLocalPath = String(CCUtility.getDirectoryUserData()) + "/" + userUrlBase + "-" + tableShare.shareWith + ".png"
                 NCOperationQueue.shared.downloadAvatar(user: tableShare.shareWith, userUrlBase: userUrlBase, fileNameLocalPath: fileNameLocalPath, placeholder: UIImage(named: "avatar"), cell: cell, view: tableView)
                 

+ 2 - 2
iOSClient/Share/NCShareComments.swift

@@ -72,7 +72,7 @@ class NCShareComments: UIViewController, NCShareCommentsCellDelegate {
         labelUser.textColor = NCBrandColor.shared.label
         
         imageItem.image = UIImage(named: "avatar")
-        let fileNameLocalPath = String(CCUtility.getDirectoryUserData()) + "/" + String(CCUtility.getStringUser(appDelegate.user, urlBase: appDelegate.urlBase)) + "-" + appDelegate.user + ".png"
+        let fileNameLocalPath = String(CCUtility.getDirectoryUserData()) + "/" + String(CCUtility.getUserUrlBase(appDelegate.user, urlBase: appDelegate.urlBase)) + "-" + appDelegate.user + ".png"
         if FileManager.default.fileExists(atPath: fileNameLocalPath) {
             if let image = UIImage(contentsOfFile: fileNameLocalPath) {
                 imageItem.image = NCUtility.shared.createAvatar(image: image, size: 40)
@@ -180,7 +180,7 @@ extension NCShareComments: UITableViewDataSource {
             cell.sizeToFit()
             
             // Image
-            let userUrlBase = String(CCUtility.getStringUser(appDelegate.user, urlBase: appDelegate.urlBase))
+            let userUrlBase = String(CCUtility.getUserUrlBase(appDelegate.user, urlBase: appDelegate.urlBase))
             let fileNameLocalPath = String(CCUtility.getDirectoryUserData()) + "/" + userUrlBase + "-" + tableComments.actorId + ".png"
             NCOperationQueue.shared.downloadAvatar(user: tableComments.actorId, userUrlBase: userUrlBase, fileNameLocalPath: fileNameLocalPath, placeholder: UIImage(named: "avatar"), cell: cell, view: tableView)
             // Username

+ 1 - 1
iOSClient/Utility/CCUtility.h

@@ -206,7 +206,7 @@
 + (void)createDirectoryStandard;
 
 + (NSURL *)getDirectoryGroup;
-+ (NSString *)getStringUser:(NSString *)user urlBase:(NSString *)urlBase;
++ (NSString *)getUserUrlBase:(NSString *)user urlBase:(NSString *)urlBase;
 + (NSString *)getDirectoryDocuments;
 + (NSString *)getDirectoryReaderMetadata;
 + (NSString *)getDirectoryAudio;

+ 1 - 1
iOSClient/Utility/CCUtility.m

@@ -1077,7 +1077,7 @@
     return path;
 }
 
-+ (NSString *)getStringUser:(NSString *)user urlBase:(NSString *)urlBase
++ (NSString *)getUserUrlBase:(NSString *)user urlBase:(NSString *)urlBase
 {
     NSString *baseUrl = [urlBase lowercaseString];
     NSString *dirUserBaseUrl = @"";