Prechádzať zdrojové kódy

Unable to mark Favorite on folder #373

Marino Faggiana 7 rokov pred
rodič
commit
712cb55224

+ 6 - 4
iOSClient/Database/NCManageDatabase.swift

@@ -405,10 +405,10 @@ class NCManageDatabase: NSObject {
         }
     }
     
-    @objc func setAccountsUserProfile(_ userProfile: OCUserProfile) {
+    @objc func setAccountsUserProfile(_ userProfile: OCUserProfile) -> tableAccount? {
      
-        guard let tblAccount = self.getAccountActive() else {
-            return
+        guard let activeAccount = self.getAccountActive() else {
+            return nil
         }
         
         let realm = try! Realm()
@@ -416,7 +416,7 @@ class NCManageDatabase: NSObject {
         do {
             try realm.write {
                 
-                guard let result = realm.objects(tableAccount.self).filter("account = %@", tblAccount.account).first else {
+                guard let result = realm.objects(tableAccount.self).filter("account = %@", activeAccount.account).first else {
                     return
                 }
                 
@@ -444,6 +444,8 @@ class NCManageDatabase: NSObject {
         } catch let error {
             print("[LOG] Could not write to database: ", error)
         }
+        
+        return activeAccount
     }
     
     //MARK: -

+ 6 - 3
iOSClient/Main/CCMain.m

@@ -1129,9 +1129,12 @@
     if (![metadataNet.account isEqualToString:appDelegate.activeAccount])
         return;
     
-    // Update User (+ userProfile.id) & account network
-    [[NCManageDatabase sharedInstance] setAccountsUserProfile:userProfile];
-    [[CCNetworking sharedNetworking] settingAccount];
+    // Update User (+ userProfile.id) & active account & account network
+    tableAccount *tableAccount = [[NCManageDatabase sharedInstance] setAccountsUserProfile:userProfile];
+    if (tableAccount) {
+        [[CCNetworking sharedNetworking] settingAccount];
+        [appDelegate settingActiveAccount:tableAccount.account activeUrl:tableAccount.url activeUser:tableAccount.user activeUserID:tableAccount.userID activePassword:tableAccount.password];
+    }
 
     dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{