marinofaggiana пре 3 година
родитељ
комит
a8943cfe9a

+ 1 - 1
Share/NCShareExtension.swift

@@ -420,7 +420,7 @@ class NCShareExtension: UIViewController, NCListCellDelegate, NCEmptyDataSetDele
         }
     }
     
-    func changeAccountRequestAddAccount(account: String) {
+    func accountRequestChangeAccount(account: String) {
         setAccount(account: account)
     }
     

+ 3 - 3
iOSClient/Account Request/NCAccountRequest.swift

@@ -26,13 +26,13 @@ import NCCommunication
 
 public protocol NCAccountRequestDelegate {
     func accountRequestAddAccount()
-    func changeAccountRequestAddAccount(account: String)
+    func accountRequestChangeAccount(account: String)
 }
 
 // optional func
 public extension NCAccountRequestDelegate {
     func accountRequestAddAccount() {}
-    func changeAccountRequestAddAccount(account: String) {}
+    func accountRequestChangeAccount(account: String) {}
 }
 
 class NCAccountRequest: UIViewController {
@@ -172,7 +172,7 @@ extension NCAccountRequest: UITableViewDelegate {
             let account = accounts[indexPath.row]
             if account.account != activeAccount?.account {
                 dismiss(animated: true) {
-                    self.delegate?.changeAccountRequestAddAccount(account: account.account)
+                    self.delegate?.accountRequestChangeAccount(account: account.account)
                 }
             } else {
                 dismiss(animated: true)

+ 9 - 3
iOSClient/AppDelegate.swift

@@ -607,9 +607,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
         }
     }
     
-    // MARK: - Account Request
-    
-    func changeAccountRequestAddAccount(account: String) {
+    @objc func changeAccount(_ account: String) {
+        
         NCManageDatabase.shared.setAccountActive(account)
         if let activeAccount = NCManageDatabase.shared.getActiveAccount() {
             
@@ -622,6 +621,13 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
         }
     }
     
+    // MARK: - Account Request
+    
+    func accountRequestChangeAccount(account: String) {
+        
+        changeAccount(account)
+    }
+    
     func requestAccount(startTimer: Bool) {
               
         let accounts = NCManageDatabase.shared.getAllAccount()

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

@@ -727,7 +727,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
         self.collectionView.reloadData()
     }
     
-    func changeAccountRequestAddAccount(account: String) {
+    func accountRequestChangeAccount(account: String) {
         NCManageDatabase.shared.setAccountActive(account)
         if let activeAccount = NCManageDatabase.shared.getActiveAccount() {
             

+ 3 - 19
iOSClient/Settings/CCManageAccount.m

@@ -385,7 +385,7 @@
     for (tableAccount *account in accounts) {
         if ([rowDescriptor.tag isEqualToString:account.account]) {
             if (![account.account isEqualToString:activeAccount.account]) {
-                [self ChangeDefaultAccount:account.account];
+                [appDelegate changeAccount:account.account];
                 [self initializeForm];
             }
         }
@@ -435,9 +435,10 @@
             NSArray *listAccount = [[NCManageDatabase shared] getAccounts];
             if ([listAccount count] > 0) {
                 if ([accountForDelete isEqualToString:activeAccount]) {
-                    [self ChangeDefaultAccount:listAccount[0]];
+                    [appDelegate changeAccount:listAccount[0]];
                 }
             }
+            
             [self initializeForm];
         }]];
         
@@ -471,21 +472,4 @@
     }
 }
 
-#pragma mark -
-
-- (void)ChangeDefaultAccount:(NSString *)account
-{
-    tableAccount *tableAccount = [[NCManageDatabase shared] setAccountActive:account];
-    if (tableAccount) {
-        
-        [[NCOperationQueue shared] cancelAllQueue];
-        [[NCNetworking shared] cancelAllTask];
-        
-        [appDelegate settingAccount:tableAccount.account urlBase:tableAccount.urlBase user:tableAccount.user userId:tableAccount.userId password:[CCUtility getPassword:tableAccount.account]];
- 
-        // Init home
-        [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:NCGlobal.shared.notificationCenterInitializeMain object:nil userInfo:nil];
-    }
-}
-
 @end