Bladeren bron

dev share

Marino Faggiana 6 jaren geleden
bovenliggende
commit
eb281b0842

+ 2 - 2
iOSClient/Favorites/CCFavorites.m

@@ -280,7 +280,7 @@
     
     tableMetadata *metadata = [[NCMainCommon sharedInstance] getMetadataFromSectionDataSourceIndexPath:indexPath sectionDataSource:sectionDataSource];
     if (metadata)
-        [appDelegate.activeMain openWindowShare:metadata];
+        [appDelegate.activeMain readShareWithAccount:appDelegate.activeAccount openWindow:YES metadata:metadata];
 }
 
 #pragma --------------------------------------------------------------------------------------------
@@ -462,7 +462,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 openWindowShare:metadata];
+        [appDelegate.activeMain readShareWithAccount:appDelegate.activeAccount openWindow:YES metadata:metadata];
     }];
     
     // NO Directory

+ 2 - 3
iOSClient/Main/CCDetail.m

@@ -565,8 +565,7 @@
 - (void)photoBrowser:(MWPhotoBrowser *)photoBrowser shareButtonPressedForPhotoAtIndex:(NSUInteger)index
 {
     tableMetadata *metadata = [self.photoDataSource objectAtIndex:index];
-    
-    [appDelegate.activeMain openWindowShare:metadata];
+    [appDelegate.activeMain readShareWithAccount:appDelegate.activeAccount openWindow:YES metadata:metadata];
 }
 
 - (void)photoBrowser:(MWPhotoBrowser *)photoBrowser deleteButtonPressedForPhotoAtIndex:(NSUInteger)index deleteButton:(UIBarButtonItem *)deleteButton
@@ -967,7 +966,7 @@
 
 - (void)shareButtonPressed:(UIBarButtonItem *)sender
 {
-    [appDelegate.activeMain openWindowShare:self.metadataDetail];
+    [appDelegate.activeMain readShareWithAccount:appDelegate.activeAccount openWindow:YES metadata:self.metadataDetail];
 }
 
 - (void)deleteButtonPressed:(UIBarButtonItem *)sender

+ 0 - 1
iOSClient/Main/CCMain.h

@@ -83,7 +83,6 @@
 
 - (void)readShareWithAccount:(NSString *)account openWindow:(BOOL)openWindow metadata:(tableMetadata *)metadata;
 
-- (void)openWindowShare:(tableMetadata *)metadata;
 - (void)clearDateReadDataSource:(NSNotification *)notification;
 - (void)cancelSearchBar;
 

+ 13 - 54
iOSClient/Main/CCMain.m

@@ -1913,7 +1913,7 @@
                     
                     [_shareOC reloadData];
                     
-                } else {
+                } else if (metadata) {
                     
                     // Apriamo la view
                     _shareOC = [[UIStoryboard storyboardWithName:@"CCShare" bundle:nil] instantiateViewControllerWithIdentifier:@"CCShareOC"];
@@ -1933,6 +1933,10 @@
             [self tableViewReloadData];
         }
     }];
+    
+    if (openWindow) {
+        [_hud visibleIndeterminateHud];
+    }
 }
 
 - (void)share:(tableMetadata *)metadata serverUrl:(NSString *)serverUrl password:(NSString *)password permission:(NSInteger)permission hideDownload:(BOOL)hideDownload
@@ -1945,7 +1949,7 @@
         
         if (errorCode == 0 && [account isEqualToString:appDelegate.activeAccount]) {
             
-            
+            [self readShareWithAccount:account openWindow:YES metadata:metadata];
             
         } else if (errorCode != 0) {
             
@@ -1980,6 +1984,8 @@
                 appDelegate.sharesUserAndGroup = result[1];
             }
             
+            [self readShareWithAccount:account openWindow:YES metadata:metadata];
+            
         } else if (errorCode != 0) {
             
             if (errorCode == kOCErrorServerUnauthorized)
@@ -2005,7 +2011,7 @@
         
         if (errorCode == 0 && [account isEqualToString:appDelegate.activeAccount]) {
             
-            
+            [self readShareWithAccount:account openWindow:YES metadata:metadata];
             
         } else if (errorCode != 0) {
             
@@ -2059,7 +2065,7 @@
         
         if (errorCode == 0 && [account isEqualToString:appDelegate.activeAccount]) {
             
-            
+            [self readShareWithAccount:account openWindow:YES metadata:metadata];
             
         } else if (errorCode != 0) {
             
@@ -2078,53 +2084,6 @@
     [_hud visibleHudTitle:NSLocalizedString(@"_creating_sharing_", nil) mode:MBProgressHUDModeIndeterminate color:nil];
 }
 
-- (void)openWindowShare:(tableMetadata *)metadata
-{
-    [[OCNetworking sharedManager] readShareWithAccount:appDelegate.activeAccount completion:^(NSString *account, NSArray *items, NSString *message, NSInteger errorCode) {
-        
-        [_hud hideHud];
-        
-        if ([account isEqualToString:appDelegate.activeAccount]) {
-        
-            for (OCSharedDto *item in items)
-                [appDelegate.sharesID setObject:item forKey:[@(item.idRemoteShared) stringValue]];
-            
-            NSArray *result = [[NCManageDatabase sharedInstance] updateShare:appDelegate.sharesID activeUrl:appDelegate.activeUrl account:account];
-            if (result) {
-                appDelegate.sharesLink = result[0];
-                appDelegate.sharesUserAndGroup = result[1];
-            }
-            
-            // Notify Shares View
-            [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:@"SharesReloadDatasource" object:nil userInfo:nil];
-            
-            if (_shareOC) {
-                
-                [_shareOC reloadData];
-                
-            } else {
-                
-                // 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];
-            }
-            
-            [self tableViewReloadData];
-        }
-    }];
-
-    [_hud visibleIndeterminateHud];
-}
-
 - (void)tapActionShared:(UITapGestureRecognizer *)tapGesture
 {
     CGPoint location = [tapGesture locationInView:self.tableView];
@@ -2133,7 +2092,7 @@
     tableMetadata *metadata = [[NCMainCommon sharedInstance] getMetadataFromSectionDataSourceIndexPath:indexPath sectionDataSource:sectionDataSource];
     
     if (metadata)
-        [self openWindowShare:metadata];
+        [appDelegate.activeMain readShareWithAccount:appDelegate.activeAccount openWindow:YES metadata:metadata];
 }
 
 - (void)tapActionConnectionMounted:(UITapGestureRecognizer *)tapGesture
@@ -3316,7 +3275,7 @@
                                      height:50.0
                                        type:AHKActionSheetButtonTypeDefault
                                     handler:^(AHKActionSheet *as) {
-                                        [self openWindowShare:self.metadata];
+                                        [appDelegate.activeMain readShareWithAccount:appDelegate.activeAccount openWindow:YES metadata:self.metadata];
                                     }];
         }
         
@@ -3506,7 +3465,7 @@
                                         height: 50.0
                                         type:AHKActionSheetButtonTypeDefault
                                         handler:^(AHKActionSheet *as) {
-                                            [self openWindowShare:self.metadata];
+                                            [appDelegate.activeMain readShareWithAccount:appDelegate.activeAccount openWindow:YES metadata:self.metadata];
                                         }];
         }
         

+ 2 - 7
iOSClient/Networking/OCNetworking.m

@@ -1125,9 +1125,7 @@
     [communication shareFileOrFolderByServer:[tableAccount.url stringByAppendingString:@"/"] andFileOrFolderPath:[fileName encodeString:NSUTF8StringEncoding] andPassword:[password encodeString:NSUTF8StringEncoding] andPermission:permission andHideDownload:hideDownload onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSString *token, NSString *redirectedServer) {
         
         completion(account, nil, 0);
-        
-        //[self readShareServer];
-        
+                
     } failureRequest :^(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer) {
         
         NSString *message = @"";
@@ -1162,7 +1160,6 @@
     
     [communication shareWith:userOrGroup shareeType:shareeType inServer:[tableAccount.url stringByAppendingString:@"/"] andFileOrFolderPath:[fileName encodeString:NSUTF8StringEncoding] andPermissions:permission onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSString *redirectedServer) {
         
-        //[self readShareServer];
         completion(account, nil, 0);
                 
     } failureRequest:^(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer) {
@@ -1198,9 +1195,7 @@
     [communication updateShare:shareID ofServerPath:[tableAccount.url stringByAppendingString:@"/"] withPasswordProtect:[password encodeString:NSUTF8StringEncoding] andExpirationTime:expirationTime andPermissions:permission andHideDownload:hideDownload onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSString *redirectedServer) {
         
         completion(account, nil, 0);
-        
-        //[self readShareServer];
-        
+                
     } failureRequest:^(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer) {
 
         NSString *message = @"";

+ 1 - 1
iOSClient/Offline/NCOffline.swift

@@ -333,7 +333,7 @@ class NCOffline: UIViewController ,UICollectionViewDataSource, UICollectionViewD
                     }
                     self.loadDatasource()
                 }
-                if item.value as? Int == 1 { self.appDelegate.activeMain.openWindowShare(metadata) }
+                if item.value as? Int == 1 { self.appDelegate.activeMain.readShare(withAccount: self.appDelegate.activeAccount, openWindow: true, metadata: 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/Shares/NCShares.m

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

+ 1 - 1
iOSClient/Viewer/NCViewerRichdocument.swift

@@ -99,7 +99,7 @@ class NCViewerRichdocument: NSObject, WKNavigationDelegate, WKScriptMessageHandl
             }
             
             if message.body as! String == "share" {
-                appDelegate.activeMain.openWindowShare(self.detail.metadataDetail)
+                appDelegate.activeMain.readShare(withAccount: appDelegate.activeAccount, openWindow: true, metadata: self.detail.metadataDetail)
             }
         }
     }