Browse Source

Create : NCNetworkingMain

Marino Faggiana 6 years ago
parent
commit
aa7c40cdb7

+ 1 - 0
iOSClient/Favorites/CCFavorites.h

@@ -46,6 +46,7 @@
 
 @property (nonatomic, weak) CCDetail *detailViewController;
 
+- (void)shouldPerformSegue;
 - (void)openIn:(tableMetadata *)metadata;
 - (void)reloadDatasource:(NSString *)fileID action:(NSInteger)action;
 - (void)listingFavorites;

+ 7 - 9
iOSClient/Favorites/CCFavorites.m

@@ -309,8 +309,7 @@
             
         } else {
             
-            if ([self shouldPerformSegue])
-                [self performSegueWithIdentifier:@"segueDetail" sender:self];
+            [self shouldPerformSegue];
         }
         
     } else {
@@ -749,8 +748,7 @@
                     
                     if (([self.metadata.typeFile isEqualToString: k_metadataTypeFile_video] || [self.metadata.typeFile isEqualToString: k_metadataTypeFile_audio] || [_metadata.typeFile isEqualToString: k_metadataTypeFile_image]) && self.metadata.e2eEncrypted == NO) {
                         
-                        if ([self shouldPerformSegue])
-                            [self performSegueWithIdentifier:@"segueDetail" sender:self];
+                        [self shouldPerformSegue];
                         
                     } else {
                         
@@ -794,20 +792,20 @@
 #pragma mark ===== Navigation ====
 #pragma --------------------------------------------------------------------------------------------
 
-- (BOOL)shouldPerformSegue
+- (void)shouldPerformSegue
 {
     // if i am in background -> exit
-    if ([[UIApplication sharedApplication] applicationState] == UIApplicationStateBackground) return NO;
+    if ([[UIApplication sharedApplication] applicationState] == UIApplicationStateBackground) return;
     
     // if i am not window -> exit
     if (self.view.window == NO)
-        return NO;
+        return;
     
     // Collapsed but i am in detail -> exit
     if (self.splitViewController.isCollapsed)
-        if (self.detailViewController.isViewLoaded && self.detailViewController.view.window) return NO;
+        if (self.detailViewController.isViewLoaded && self.detailViewController.view.window) return;
     
-    return YES;
+    [self performSegueWithIdentifier:@"segueDetail" sender:self];
 }
 
 -(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender

+ 2 - 0
iOSClient/Main/CCMain.h

@@ -69,6 +69,8 @@
 
 - (void)openIn:(tableMetadata *)metadata;
 
+- (void)shouldPerformSegue;
+
 - (void)closeAllMenu;
 - (void)returnCreate:(NSInteger)type;
 

+ 7 - 10
iOSClient/Main/CCMain.m

@@ -1120,9 +1120,7 @@
             } else {
                 
                 self.metadata = metadata;
-                
-                if ([self shouldPerformSegue])
-                    [self performSegueWithIdentifier:@"segueDetail" sender:self];
+                [self shouldPerformSegue];
             }
         }
         
@@ -4391,8 +4389,7 @@
             
                 if (([self.metadata.typeFile isEqualToString: k_metadataTypeFile_video] || [self.metadata.typeFile isEqualToString: k_metadataTypeFile_audio] || [self.metadata.typeFile isEqualToString: k_metadataTypeFile_image]) && _metadataFolder.e2eEncrypted == NO) {
                     
-                    if ([self shouldPerformSegue])
-                        [self performSegueWithIdentifier:@"segueDetail" sender:self];
+                    [self shouldPerformSegue];
                     
                 } else {
                    
@@ -4465,19 +4462,19 @@
 #pragma mark ===== Navigation ====
 #pragma --------------------------------------------------------------------------------------------
 
-- (BOOL)shouldPerformSegue
+- (void)shouldPerformSegue
 {
     // if background return
-    if ([[UIApplication sharedApplication] applicationState] == UIApplicationStateBackground) return NO;
+    if ([[UIApplication sharedApplication] applicationState] == UIApplicationStateBackground) return;
     
     if (self.view.window == NO)
-        return NO;
+        return;
     
     // Collapsed ma siamo già in detail esci
     if (self.splitViewController.isCollapsed)
-        if (_detailViewController.isViewLoaded && _detailViewController.view.window) return NO;
+        if (_detailViewController.isViewLoaded && _detailViewController.view.window) return;
     
-    return YES;
+    [self performSegueWithIdentifier:@"segueDetail" sender:self];
 }
 
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender

+ 9 - 0
iOSClient/Main/NCMainCommon.swift

@@ -724,6 +724,15 @@ class NCNetworkingMain: NSObject, CCNetworkingDelegate {
                     }
                     
                 } else {
+                    
+                    if appDelegate.activeMain.view.window != nil {
+                        appDelegate.activeMain.metadata = metadata;
+                        appDelegate.activeMain.shouldPerformSegue()
+                    }
+                    if appDelegate.activeFavorites.view.window != nil {
+                        appDelegate.activeFavorites.metadata = metadata;
+                        appDelegate.activeMain.shouldPerformSegue()
+                    }
                 }
             }
         }