marinofaggiana 4 жил өмнө
parent
commit
95c57b2ded

+ 10 - 0
iOSClient/Data/NCManageDatabase.swift

@@ -382,6 +382,16 @@ class NCManageDatabase: NSObject {
         return Array(results.map { tableAccount.init(value:$0) })
     }
     
+    @objc func getAllAccountOrderAlias() -> [tableAccount] {
+        
+        let realm = try! Realm()
+        
+        let sorted = [SortDescriptor(keyPath: "active", ascending: false), SortDescriptor(keyPath: "alias", ascending: true), SortDescriptor(keyPath: "user", ascending: true)]
+        let results = realm.objects(tableAccount.self).sorted(by: sorted)
+        
+        return Array(results.map { tableAccount.init(value:$0) })
+    }
+    
     @objc func getAccountAutoUploadFileName() -> String {
         
         let realm = try! Realm()

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

@@ -662,7 +662,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
     
     @objc func profileButtonTapped(sender: Any) {
         
-        let accounts = NCManageDatabase.shared.getAllAccount()
+        let accounts = NCManageDatabase.shared.getAllAccountOrderAlias()
         if accounts.count > 0 {
             
             if let vcAccountRequest = UIStoryboard(name: "NCAccountRequest", bundle: nil).instantiateInitialViewController() as? NCAccountRequest {