瀏覽代碼

clear code

marinofaggiana 4 年之前
父節點
當前提交
bdcfb61ed2

+ 10 - 11
iOSClient/AppDelegate.m

@@ -141,7 +141,9 @@
         if (self.account.length == 0) {
             [self openLoginView:nil selector:k_intro_login openLoginWeb:false];
         }
+        
     } else {
+        
         if ([CCUtility getIntro] == NO) {
             UIViewController *introViewController = [[UIStoryboard storyboardWithName:@"NCIntro" bundle:[NSBundle mainBundle]] instantiateInitialViewController];
             
@@ -170,7 +172,7 @@
 //
 - (void)applicationWillResignActive:(UIApplication *)application
 {
-    if (self.account.length == 0) return;
+    if (self.account.length == 0) { return; }
     
     // Dismiss FileViewInFolder
     if (self.activeFileViewInFolder != nil ) {
@@ -257,7 +259,7 @@
 // NotificationCenter
 - (void)initializeMain:(NSNotification *)notification
 {
-    if (self.account.length == 0) return;
+    if (self.account.length == 0) { return; }
     
     // Clear error certificate
     [CCUtility setCertificateError:self.account error:NO];
@@ -297,8 +299,7 @@
 
 - (void)checkErrorNetworking
 {
-    // test
-    if (self.account.length == 0) return;
+    if (self.account.length == 0) { return; }
     
     // check unauthorized server (401)
     if ([CCUtility getPassword:self.account].length == 0) {
@@ -502,8 +503,7 @@
 
 - (void)pushNotification
 {
-    // test
-    if (self.account.length == 0 || self.pushKitToken.length == 0) return;
+    if (self.account.length == 0 || self.pushKitToken.length == 0) { return; }
     
     for (tableAccount *result in [[NCManageDatabase sharedInstance] getAllAccount]) {
         
@@ -522,8 +522,7 @@
 
 - (void)subscribingNextcloudServerPushNotification:(NSString *)account urlBase:(NSString *)urlBase user:(NSString *)user
 {
-    // test
-    if (self.account.length == 0 || self.pushKitToken.length == 0) return;
+    if (self.account.length == 0 || self.pushKitToken.length == 0) { return; }
     
     [[NCPushNotificationEncryption sharedInstance] generatePushNotificationsKeyPair:account];
 
@@ -552,7 +551,7 @@
 
 - (void)unsubscribingNextcloudServerPushNotification:(NSString *)account urlBase:(NSString *)urlBase user:(NSString *)user withSubscribing:(BOOL)subscribing
 {
-    if (self.account.length == 0) return;
+    if (self.account.length == 0) { return; }
     
     NSString *deviceIdentifier = [CCUtility getPushNotificationDeviceIdentifier:account];
     NSString *signature = [CCUtility getPushNotificationDeviceIdentifierSignature:account];
@@ -685,7 +684,7 @@
 
 - (void)updateApplicationIconBadgeNumber
 {
-    if (self.account.length == 0) return;
+    if (self.account.length == 0) { return; }
             
     NSInteger counterDownload = [[NCOperationQueue shared] downloadCount];
     NSInteger counterUpload = [[NCManageDatabase sharedInstance] getMetadatasWithPredicate:[NSPredicate predicateWithFormat:@"status == %d OR status == %d OR status == %d", k_metadataStatusWaitUpload, k_metadataStatusInUpload, k_metadataStatusUploading]].count;
@@ -755,7 +754,7 @@
 // Method called from iOS system to send a file from other app.
 - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url options:(NSDictionary<NSString *,id> *)options
 {
-    if (self.account.length == 0) return YES;
+    if (self.account.length == 0) { return YES; }
     
     NSString *scheme = url.scheme;
     NSString *fileName;

+ 6 - 3
iOSClient/Main/Colleaction Common/NCCollectionViewCommon.swift

@@ -235,7 +235,8 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
     // MARK: - NotificationCenter
 
     @objc func initializeMain() {
-        if appDelegate.account.count == 0 { return }
+        
+        if appDelegate.account == nil || appDelegate.account.count == 0 { return }
         
         if searchController?.isActive ?? false {
             searchController?.isActive = false
@@ -901,7 +902,8 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
     // MARK: - DataSource + NC Endpoint
     
     @objc func reloadDataSource() {
-        if appDelegate.account.count == 0 { return }
+        
+        if appDelegate.account == nil || appDelegate.account.count == 0 { return }
         
         // Get richWorkspace Text
         let directory = NCManageDatabase.sharedInstance.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", appDelegate.account, serverUrl))
@@ -922,7 +924,8 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
         reloadDataSourceNetwork(forced: true)
     }
     @objc func networkSearch() {
-        if appDelegate.account.count == 0 { return }
+        
+        if appDelegate.account == nil || appDelegate.account.count == 0 { return }
         
         if literalSearch?.count ?? 0 > 1 {
         

+ 1 - 1
iOSClient/Media/NCMedia.swift

@@ -627,7 +627,7 @@ extension NCMedia {
     
     @objc func reloadDataSourceWithCompletion(_ completion: @escaping (_ metadatas: [tableMetadata]) -> Void) {
         
-        if (appDelegate.account == nil || appDelegate.account.count == 0) { return }
+        if appDelegate.account == nil || appDelegate.account.count == 0 { return }
         
         if account != appDelegate.account {
             self.metadatas = []

+ 2 - 2
iOSClient/Networking/NCNetworkingAutoUpload.swift

@@ -46,13 +46,13 @@ class NCNetworkingAutoUpload: NSObject {
 
     @objc private func process() {
 
+        if appDelegate.account == nil || appDelegate.account.count == 0 { return }
+        
         var counterUpload: Int = 0
         var sizeUpload = 0
         var maxConcurrentOperationUpload = 5
         let sessionSelectors = [selectorUploadFile, selectorUploadAutoUpload, selectorUploadAutoUploadAll]
         
-        if appDelegate.account == nil || appDelegate.account.count == 0 { return }
-        
         let metadatasUpload = NCManageDatabase.sharedInstance.getMetadatas(predicate: NSPredicate(format: "status == %d OR status == %d", k_metadataStatusInUpload, k_metadataStatusUploading))
         counterUpload = metadatasUpload.count
         for metadata in metadatasUpload {

+ 3 - 3
iOSClient/Networking/NCService.swift

@@ -37,7 +37,7 @@ class NCService: NSObject {
     
     @objc public func startRequestServicesServer() {
    
-        if (appDelegate.account == nil || appDelegate.account.count == 0) { return }
+        if appDelegate.account == nil || appDelegate.account.count == 0 { return }
         
         self.requestUserProfile()
         self.requestServerStatus()
@@ -47,7 +47,7 @@ class NCService: NSObject {
     
     private func requestUserProfile() {
         
-        if (appDelegate.account == nil || appDelegate.account.count == 0) { return }
+        if appDelegate.account == nil || appDelegate.account.count == 0 { return }
         
         NCCommunication.shared.getUserProfile() { (account, userProfile, errorCode, errorDescription) in
                
@@ -138,7 +138,7 @@ class NCService: NSObject {
     
     private func requestServerCapabilities() {
         
-        if (appDelegate.account == nil || appDelegate.account.count == 0) { return }
+        if appDelegate.account == nil || appDelegate.account.count == 0 { return }
         
         NCCommunication.shared.getCapabilities() { (account, data, errorCode, errorDescription) in