Marino Faggiana 7 жил өмнө
parent
commit
007e89f050

+ 4 - 0
iOSClient/Main/CCMain.h

@@ -65,10 +65,14 @@
 @property (nonatomic, strong) UIView *reMenuBackgroundView;
 @property (nonatomic, strong) UIView *reMenuBackgroundView;
 @property (nonatomic, strong) UITapGestureRecognizer *singleFingerTap;
 @property (nonatomic, strong) UITapGestureRecognizer *singleFingerTap;
 @property (nonatomic, strong) UIImage *imageTitle;
 @property (nonatomic, strong) UIImage *imageTitle;
+@property BOOL isSelectedMode;
+
 
 
 - (void)closeAllMenu;
 - (void)closeAllMenu;
 - (void)returnCreate:(NSInteger)type;
 - (void)returnCreate:(NSInteger)type;
 
 
+- (void)setUINavigationBarDefault;
+
 - (void)readFolder:(NSString *)serverUrl;
 - (void)readFolder:(NSString *)serverUrl;
 - (void)readFileReloadFolder;
 - (void)readFileReloadFolder;
 
 

+ 1 - 29
iOSClient/Main/CCMain.m

@@ -46,8 +46,6 @@
     BOOL _isRoot;
     BOOL _isRoot;
     BOOL _isViewDidLoad;
     BOOL _isViewDidLoad;
     
     
-    BOOL _isSelectedMode;
-        
     NSMutableDictionary *_selectedFileIDsMetadatas;
     NSMutableDictionary *_selectedFileIDsMetadatas;
     NSUInteger _numSelectedFileIDsMetadatas;
     NSUInteger _numSelectedFileIDsMetadatas;
     NSMutableArray *_queueSelector;
     NSMutableArray *_queueSelector;
@@ -982,32 +980,6 @@
 
 
 #pragma mark -
 #pragma mark -
 
 
-#pragma --------------------------------------------------------------------------------------------
-#pragma mark ==== Activity ====
-#pragma --------------------------------------------------------------------------------------------
-
-- (void)getActivityServerSuccessFailure:(CCMetadataNet *)metadataNet listOfActivity:(NSArray *)listOfActivity message:(NSString *)message errorCode:(NSInteger)errorCode
-{
-    // Check Active Account
-    if (![metadataNet.account isEqualToString:appDelegate.activeAccount])
-        return;
-    
-    if (errorCode == 0) {
-        
-        [[NCManageDatabase sharedInstance] addActivityServer:listOfActivity];
-        
-        // Reload Activity Data Source
-        [appDelegate.activeActivity reloadDatasource];
-        
-    } else {
-    
-        NSString *error = [NSString stringWithFormat:@"Get Activity Server failure error %d, %@", (int)errorCode, message];
-        NSLog(@"[LOG] %@", error);
-        
-        [[NCManageDatabase sharedInstance] addActivityClient:@"" fileID:@"" action:k_activityDebugActionCapabilities selector:@"Get Activity Server" note:error type:k_activityTypeFailure verbose:k_activityVerboseHigh activeUrl:appDelegate.activeUrl];
-    }
-}
-
 #pragma --------------------------------------------------------------------------------------------
 #pragma --------------------------------------------------------------------------------------------
 #pragma mark ==== Notification  ====
 #pragma mark ==== Notification  ====
 #pragma --------------------------------------------------------------------------------------------
 #pragma --------------------------------------------------------------------------------------------
@@ -1147,7 +1119,7 @@
         
         
         // Read Notification
         // Read Notification
         metadataNet.action = actionGetNotificationServer;
         metadataNet.action = actionGetNotificationServer;
-        [appDelegate addNetworkingOperationQueue:appDelegate.netQueue delegate:self metadataNet:metadataNet];
+        [appDelegate addNetworkingOperationQueue:appDelegate.netQueue delegate:NCService.sharedInstance metadataNet:metadataNet];
         
         
         // Read Activity
         // Read Activity
         metadataNet.action = actionGetActivityServer;
         metadataNet.action = actionGetActivityServer;

+ 57 - 0
iOSClient/Networking/NCService.swift

@@ -208,6 +208,63 @@ class NCService: NSObject, OCNetworkingDelegate, CCLoginDelegate, CCLoginDelegat
         }
         }
     }
     }
     
     
+    @objc func getNotificationServerSuccessFailure(_ metadataNet: CCMetadataNet!, listOfNotifications: [Any]?, message: String?, errorCode: Int) {
+    
+        // Check Active Account
+        if (metadataNet.account != appDelegate.activeAccount) {
+            return;
+        }
+        
+        if (errorCode == 0) {
+            
+            DispatchQueue.global(qos: .default).async {
+
+                let sortedListOfNotifications = (listOfNotifications! as NSArray).sortedArray(using: [
+                    NSSortDescriptor(key: "date", ascending: false)
+                ])
+                
+                var old = ""
+                var new = ""
+                
+                for notification in listOfNotifications! {
+                    let id = (notification as AnyObject).idNotification!
+                    new = new + String(describing: id)
+                }
+                for notification in self.appDelegate.listOfNotifications! {
+                    let id = (notification as AnyObject).idNotification!
+                    old = old + String(describing: id)
+                }
+                
+                
+                DispatchQueue.main.async {
+                
+                    if (new != old) {
+                    
+                        self.appDelegate.listOfNotifications = NSMutableArray.init(array: sortedListOfNotifications)
+                        NotificationCenter.default.post(name: NSNotification.Name(rawValue: "notificationReloadData"), object: nil)
+                
+                        // Update Main NavigationBar
+                        if (self.appDelegate.activeMain.isSelectedMode == false) {
+                            self.appDelegate.activeMain.setUINavigationBarDefault()
+                        }
+                    }
+                }
+            }
+            
+        } else {
+            
+            let error = "Get Notification Server failure error \(errorCode) \(message!)"
+            print("[LOG] \(error)")
+            
+            NCManageDatabase.sharedInstance.addActivityClient("", fileID: "", action: k_activityDebugActionCapabilities, selector: "Get Notification Server", note: error, type: k_activityTypeFailure, verbose: true, activeUrl: appDelegate.activeUrl)
+            
+            // Update Main NavigationBar
+            if (appDelegate.activeMain.isSelectedMode == false) {
+                appDelegate.activeMain.setUINavigationBarDefault()
+            }
+        }
+    }
+    
     //MARK: -
     //MARK: -
     //MARK: Delegate : Login
     //MARK: Delegate : Login