瀏覽代碼

clear code

marinofaggiana 5 年之前
父節點
當前提交
41e8a3c0f4

+ 0 - 1
iOSClient/AppDelegate.m

@@ -640,7 +640,6 @@ PKPushRegistry *pushRegistry;
         self.sharesUserAndGroup = result[1];
     }
     
-    // Notify Shares View
     [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:@"SharesReloadDatasource" object:nil userInfo:nil];
 }
 

+ 2 - 2
iOSClient/Favorites/CCFavorites.m

@@ -257,7 +257,7 @@
     
     tableMetadata *metadata = [[NCMainCommon sharedInstance] getMetadataFromSectionDataSourceIndexPath:indexPath sectionDataSource:sectionDataSource];
     if (metadata)
-        [appDelegate.activeMain readShareWithAccount:appDelegate.activeAccount metadata:metadata];
+        [appDelegate.activeMain openShareWithMetadata:metadata];
 }
 
 #pragma --------------------------------------------------------------------------------------------
@@ -476,7 +476,7 @@
     // Share
     [actionSheet addButtonWithTitle:NSLocalizedString(@"_share_", nil) image:[CCGraphics changeThemingColorImage:[UIImage imageNamed:@"share"] multiplier:2 color:[NCBrandColor sharedInstance].brandElement] backgroundColor:[NCBrandColor sharedInstance].backgroundView height: 50.0 type:AHKActionSheetButtonTypeDefault handler:^(AHKActionSheet *as) {
         
-        [appDelegate.activeMain readShareWithAccount:appDelegate.activeAccount metadata:metadata];
+        [appDelegate.activeMain openShareWithMetadata:metadata];
     }];
     
     // NO Directory

+ 2 - 2
iOSClient/Main/CCDetail.m

@@ -591,7 +591,7 @@
 - (void)photoBrowser:(MWPhotoBrowser *)photoBrowser shareButtonPressedForPhotoAtIndex:(NSUInteger)index
 {
     tableMetadata *metadata = [self.photoDataSource objectAtIndex:index];
-    [appDelegate.activeMain readShareWithAccount:appDelegate.activeAccount metadata:metadata];
+    [appDelegate.activeMain openShareWithMetadata:metadata];
 }
 
 - (void)photoBrowser:(MWPhotoBrowser *)photoBrowser deleteButtonPressedForPhotoAtIndex:(NSUInteger)index deleteButton:(UIBarButtonItem *)deleteButton
@@ -988,7 +988,7 @@
 
 - (void)shareButtonPressed:(UIBarButtonItem *)sender
 {
-    [appDelegate.activeMain readShareWithAccount:appDelegate.activeAccount metadata:self.metadataDetail];
+    [appDelegate.activeMain openShareWithMetadata:self.metadataDetail];
 }
 
 - (void)deleteButtonPressed:(UIBarButtonItem *)sender

+ 1 - 1
iOSClient/Main/CCMain.h

@@ -81,7 +81,7 @@
 
 - (void)reloadDatasource:(NSString *)serverUrl fileID:(NSString *)fileID action:(NSInteger)action;
 
-- (void)readShareWithAccount:(NSString *)account metadata:(tableMetadata *)metadata;
+- (void)openShareWithMetadata:(tableMetadata *)metadata;
 
 - (void)clearDateReadDataSource:(NSNotification *)notification;
 - (void)cancelSearchBar;

+ 33 - 9
iOSClient/Main/CCMain.m

@@ -1870,8 +1870,30 @@
 #pragma mark ===== Shared =====
 #pragma --------------------------------------------------------------------------------------------
 
-- (void)readShareWithAccount:(NSString *)account metadata:(tableMetadata *)metadata
+- (void)openShareWithMetadata:(tableMetadata *)metadata
 {
+    if (_shareOC) {
+        
+        [_shareOC reloadData];
+        
+    } else if (metadata) {
+        
+        // Apriamo la view
+        _shareOC = [[UIStoryboard storyboardWithName:@"CCShare" bundle:nil] instantiateViewControllerWithIdentifier:@"CCShareOC"];
+        
+        _shareOC.delegate = self;
+        _shareOC.metadata = metadata;
+        _shareOC.serverUrl = metadata.serverUrl;
+        
+        _shareOC.shareLink = [appDelegate.sharesLink objectForKey:metadata.fileID];
+        _shareOC.shareUserAndGroup = [appDelegate.sharesUserAndGroup objectForKey:metadata.fileID];
+        
+        [_shareOC setModalPresentationStyle:UIModalPresentationFormSheet];
+        [self presentViewController:_shareOC animated:YES completion:nil];
+    }
+    
+    
+    /*
     [[OCNetworking sharedManager] readShareWithAccount:account path:@"/" completion:^(NSString *account, NSArray *items, NSString *message, NSInteger errorCode) {
         
         [_hud hideHud];
@@ -1921,6 +1943,7 @@
     }];
     
     [_hud visibleIndeterminateHud];
+    */
 }
 
 - (void)share:(tableMetadata *)metadata serverUrl:(NSString *)serverUrl password:(NSString *)password permission:(NSInteger)permission hideDownload:(BOOL)hideDownload
@@ -1933,7 +1956,7 @@
         
         if (errorCode == 0 && [account isEqualToString:appDelegate.activeAccount]) {
             
-            [self readShareWithAccount:account metadata:metadata];
+            [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:@"SharesReloadDatasource" object:nil userInfo:nil];
             
         } else if (errorCode != 0) {
             
@@ -1965,7 +1988,7 @@
                 appDelegate.sharesUserAndGroup = result[1];
             }
             
-            [self readShareWithAccount:account metadata:metadata];
+            [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:@"SharesReloadDatasource" object:nil userInfo:nil];
             
         } else if (errorCode != 0) {
             
@@ -1989,7 +2012,7 @@
         
         if (errorCode == 0 && [account isEqualToString:appDelegate.activeAccount]) {
             
-            [self readShareWithAccount:account metadata:metadata];
+            [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:@"SharesReloadDatasource" object:nil userInfo:nil];
             
         } else if (errorCode != 0) {
             
@@ -2037,7 +2060,7 @@
         
         if (errorCode == 0 && [account isEqualToString:appDelegate.activeAccount]) {
             
-            [self readShareWithAccount:account metadata:metadata];
+            [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:@"SharesReloadDatasource" object:nil userInfo:nil];
             
         } else if (errorCode != 0) {
             
@@ -2060,8 +2083,9 @@
     
     tableMetadata *metadata = [[NCMainCommon sharedInstance] getMetadataFromSectionDataSourceIndexPath:indexPath sectionDataSource:sectionDataSource];
     
-    if (metadata)
-        [appDelegate.activeMain readShareWithAccount:appDelegate.activeAccount metadata:metadata];
+    if (metadata) {
+        [self openShareWithMetadata:metadata];
+    }
 }
 
 - (void)tapActionConnectionMounted:(UITapGestureRecognizer *)tapGesture
@@ -3199,7 +3223,7 @@
                                      height:50.0
                                        type:AHKActionSheetButtonTypeDefault
                                     handler:^(AHKActionSheet *as) {
-                                        [appDelegate.activeMain readShareWithAccount:appDelegate.activeAccount metadata:self.metadata];
+                                        [self openShareWithMetadata:self.metadata];
                                     }];
         }
         
@@ -3388,7 +3412,7 @@
                                         height: 50.0
                                         type:AHKActionSheetButtonTypeDefault
                                         handler:^(AHKActionSheet *as) {
-                                            [appDelegate.activeMain readShareWithAccount:appDelegate.activeAccount metadata:self.metadata];
+                                            [self openShareWithMetadata:self.metadata];
                                         }];
         }
         

+ 1 - 1
iOSClient/Offline/NCOffline.swift

@@ -338,7 +338,7 @@ class NCOffline: UIViewController, UIGestureRecognizerDelegate, NCListCellDelega
                     }
                     self.loadDatasource()
                 }
-                if item.value as? Int == 1 { self.appDelegate.activeMain.readShare(withAccount: self.appDelegate.activeAccount, metadata: metadata) }
+                if item.value as? Int == 1 { self.appDelegate.activeMain.openShare(with: metadata) }
                 if item.value as? Int == 2 { self.deleteItem(with: metadata, sender: sender) }
                 if item is ActionSheetCancelButton { print("Cancel buttons has the value `true`") }
             }

+ 1 - 1
iOSClient/PeekPop/CCPeekPop.m

@@ -78,7 +78,7 @@
     
     if (self.showShare) {
         UIPreviewAction *share = [UIPreviewAction actionWithTitle:NSLocalizedString(@"_share_", nil) style:UIPreviewActionStyleDefault handler:^(UIPreviewAction *action,  UIViewController *previewViewController){
-            [appDelegate.activeMain readShareWithAccount:appDelegate.activeAccount metadata:self.metadata];
+            [appDelegate.activeMain openShareWithMetadata:self.metadata];
         }];
         [items addObject:share];
     }

+ 1 - 1
iOSClient/Shares/NCShares.m

@@ -357,7 +357,7 @@
         
         metadata = [[NCManageDatabase sharedInstance] getMetadataWithPredicate:[NSPredicate predicateWithFormat:@"account == %@ AND serverUrl == %@ AND fileName == %@", appDelegate.activeAccount, table.serverUrl, table.fileName]];
         if (metadata) {
-            [appDelegate.activeMain readShareWithAccount:appDelegate.activeAccount metadata:metadata];
+            [appDelegate.activeMain openShareWithMetadata:metadata];
         }
     }
 }

+ 1 - 1
iOSClient/Viewer/NCViewerRichdocument.swift

@@ -109,7 +109,7 @@ class NCViewerRichdocument: WKWebView, WKNavigationDelegate, WKScriptMessageHand
             }
             
             if message.body as! String == "share" {
-                appDelegate.activeMain.readShare(withAccount: appDelegate.activeAccount, metadata: self.detail.metadataDetail)
+                appDelegate.activeMain.openShare(with: self.detail.metadataDetail)
             }
         }
     }