Browse Source

modify push for detail with added metadataForPushDetail

Marino Faggiana 6 years ago
parent
commit
0a7c48e3a9

+ 1 - 1
Nextcloud.xcodeproj/project.pbxproj

@@ -2807,8 +2807,8 @@
 		F7DFB7E9219C5A0500680748 /* Create cloud */ = {
 			isa = PBXGroup;
 			children = (
-				F7ECBA6C1E239DCD003E6328 /* NCCreateFormUploadRichdocuments.swift */,
 				F7DFB7F5219C5F2300680748 /* NCCreateFormUploadRichdocuments.storyboard */,
+				F7ECBA6C1E239DCD003E6328 /* NCCreateFormUploadRichdocuments.swift */,
 				F7DFB7F3219C5CA800680748 /* NCCreateFormUploadScanDocument.swift */,
 				F7DFB7F1219C5C0000680748 /* NCCreateFormUploadFileText.swift */,
 				F7DFB7EF219C5B8000680748 /* NCCreateFormUploadAssets.swift */,

+ 2 - 1
iOSClient/Favorites/CCFavorites.h

@@ -40,12 +40,13 @@
 @property (nonatomic, weak) IBOutlet UITableView *tableView;
 
 @property (nonatomic, strong) tableMetadata *metadata;
+@property (nonatomic, strong) tableMetadata *metadataForPushDetail;
 @property (nonatomic, strong) NSString *serverUrl;
 @property (nonatomic, strong) NSString *titleViewControl;
 
 @property (nonatomic, weak) CCDetail *detailViewController;
 
-- (void)shouldPerformSegue;
+- (void)shouldPerformSegue:(tableMetadata *)metadata;
 - (void)openIn:(tableMetadata *)metadata;
 - (void)reloadDatasource:(NSString *)fileID action:(NSInteger)action;
 - (void)listingFavorites;

+ 6 - 3
iOSClient/Favorites/CCFavorites.m

@@ -724,7 +724,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) {
                         
-                        [self shouldPerformSegue];
+                        [self shouldPerformSegue:self.metadata];
                         
                     } else {
                         
@@ -768,7 +768,7 @@
 #pragma mark ===== Navigation ====
 #pragma --------------------------------------------------------------------------------------------
 
-- (void)shouldPerformSegue
+- (void)shouldPerformSegue:(tableMetadata *)metadata
 {
     // if i am in background -> exit
     if ([[UIApplication sharedApplication] applicationState] == UIApplicationStateBackground) return;
@@ -781,6 +781,9 @@
     if (self.splitViewController.isCollapsed)
         if (self.detailViewController.isViewLoaded && self.detailViewController.view.window) return;
     
+    // Metadata for push detail
+    self.metadataForPushDetail = metadata;
+    
     [self performSegueWithIdentifier:@"segueDetail" sender:self];
 }
 
@@ -803,7 +806,7 @@
             [photoDataSource addObject:metadata];
     }
     
-    _detailViewController.metadataDetail = self.metadata;
+    _detailViewController.metadataDetail = self.metadataForPushDetail;
     _detailViewController.dateFilterQuery = nil;
     _detailViewController.photoDataSource = photoDataSource;
     

+ 2 - 1
iOSClient/Main/CCMain.h

@@ -51,6 +51,7 @@
 
 @property (nonatomic, weak) IBOutlet UITableView *tableView;
 @property (nonatomic, strong) tableMetadata *metadata;
+@property (nonatomic, strong) tableMetadata *metadataForPushDetail;
 @property (nonatomic, strong) NSString *serverUrl;
 @property (nonatomic, strong) NSString *titleMain;
 @property (nonatomic, weak) CCShareOC *shareOC;
@@ -63,7 +64,7 @@
 
 - (void)openIn:(tableMetadata *)metadata;
 
-- (void)shouldPerformSegue;
+- (void)shouldPerformSegue:(tableMetadata *)metadata;
 
 - (void)saveToPhotoAlbum:(tableMetadata *)metadata;
 

+ 7 - 4
iOSClient/Main/CCMain.m

@@ -4356,11 +4356,11 @@
             
                 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) {
                     
-                    [self shouldPerformSegue];
+                    [self shouldPerformSegue:self.metadata];
                     
                 } if ([self.metadata.typeFile isEqualToString: k_metadataTypeFile_document] && [[NCViewerRichdocument sharedInstance] isRichDocument:self.metadata]) {
                     
-                    [self shouldPerformSegue];
+                    [self shouldPerformSegue:self.metadata];
                     
                 } else {
                    
@@ -4433,7 +4433,7 @@
 #pragma mark ===== Navigation ====
 #pragma --------------------------------------------------------------------------------------------
 
-- (void)shouldPerformSegue
+- (void)shouldPerformSegue:(tableMetadata *)metadata
 {
     // if background return
     if ([[UIApplication sharedApplication] applicationState] == UIApplicationStateBackground) return;
@@ -4445,6 +4445,9 @@
     if (self.splitViewController.isCollapsed)
         if (_detailViewController.isViewLoaded && _detailViewController.view.window) return;
     
+    // Metadata for push detail
+    self.metadataForPushDetail = metadata;
+    
     [self performSegueWithIdentifier:@"segueDetail" sender:self];
 }
 
@@ -4472,7 +4475,7 @@
         
     } else {
         
-        metadata = self.metadata;
+        metadata = self.metadataForPushDetail;
         
         for (NSString *fileID in sectionDataSource.allFileID) {
             tableMetadata *metadata = [sectionDataSource.allRecordsDataSource objectForKey:fileID];

+ 11 - 2
iOSClient/Main/Create cloud/NCCreateFormUploadRichdocuments.swift

@@ -243,7 +243,6 @@ class NCCreateFormUploadRichdocuments: XLFormViewController, NCSelectDelegate, U
         guard let selectTemplate = self.selectTemplate else {
             return
         }
-        
         let rowFileName : XLFormRowDescriptor  = self.form.formRow(withTag: "fileName")!
         guard let fileNameForm = rowFileName.value else {
             return
@@ -251,14 +250,24 @@ class NCCreateFormUploadRichdocuments: XLFormViewController, NCSelectDelegate, U
         if fileNameForm as! String == "" {
             return
         } else {
+            
             fileName = (fileNameForm as! NSString).deletingPathExtension + "." + fileNameExtension
+            fileName = CCUtility.returnFileNamePath(fromFileName: fileName, serverUrl: serverUrl, activeUrl: appDelegate.activeUrl)
+        }
+        guard let directoryID = NCManageDatabase.sharedInstance.getDirectoryID(self.serverUrl) else {
+            return
         }
         
         let ocNetworking = OCnetworking.init(delegate: nil, metadataNet: nil, withUser: appDelegate.activeUser, withUserID: appDelegate.activeUserID, withPassword: appDelegate.activePassword, withUrl: appDelegate.activeUrl)
         
         ocNetworking?.createNewRichdocuments(withFileName: fileName, serverUrl: serverUrl, templateID: "\(selectTemplate.templateID)", success: { (path) in
             if path != nil && path!.count > 0 {
-                print("x")
+
+                
+                let metadataDetail = CCUtility.createMetadata(withAccount: self.appDelegate.activeAccount, date: Date(), directory: false, fileID: CCUtility.createRandomString(12), directoryID: directoryID, fileName: (fileNameForm as! NSString).deletingPathExtension + "." + self.fileNameExtension, etag: "", size: 0, status: Double(k_metadataStatusNormal))
+                
+                
+                
             }
         }, failure: { (message, errorCode) in
             self.appDelegate.messageNotification("_error_", description: message, visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.error, errorCode: errorCode)

+ 2 - 4
iOSClient/Main/NCMainCommon.swift

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