Explorar o código

fix templates

marinofaggiana %!s(int64=4) %!d(string=hai) anos
pai
achega
f6a78e6c7f
Modificáronse 1 ficheiros con 47 adicións e 34 borrados
  1. 47 34
      iOSClient/Main/Create cloud/NCCreateFormUploadDocuments.swift

+ 47 - 34
iOSClient/Main/Create cloud/NCCreateFormUploadDocuments.swift

@@ -382,7 +382,7 @@ import NCCommunication
         
         
         if self.editorId == k_editor_text || self.editorId == k_editor_onlyoffice {
         if self.editorId == k_editor_text || self.editorId == k_editor_onlyoffice {
             
             
-            fileNameExtension = "md"            
+            fileNameExtension = "md"
             var customUserAgent: String?
             var customUserAgent: String?
                        
                        
             if self.editorId == k_editor_onlyoffice {
             if self.editorId == k_editor_onlyoffice {
@@ -413,38 +413,33 @@ import NCCommunication
                             self.navigationItem.rightBarButtonItem?.isEnabled = true
                             self.navigationItem.rightBarButtonItem?.isEnabled = true
                         }
                         }
                     }
                     }
+                }
                     
                     
-                    // NOT ALIGNED getTemplatesRichdocuments
-                    if templates.count == 0 {
-                        let temp = NCCommunicationEditorTemplates()
-                        
-                        temp.identifier = ""
-                        if self.editorId == k_editor_text {
-                            temp.ext = "md"
-                        } else if self.editorId == k_editor_onlyoffice && self.typeTemplate == k_template_document {
-                            temp.ext = "docx"
-                        } else if self.editorId == k_editor_onlyoffice && self.typeTemplate == k_template_spreadsheet {
-                            temp.ext = "xlsx"
-                        } else if self.editorId == k_editor_onlyoffice && self.typeTemplate == k_template_presentation {
-                            temp.ext = "pptx"
-                        }
-                        temp.name = "Empty"
-                        temp.preview = ""
-                                                                      
-                        self.listOfTemplate.append(temp)
-                        
-                        self.selectTemplate = temp
-                        self.fileNameExtension = temp.ext
-                        self.navigationItem.rightBarButtonItem?.isEnabled = true
+                if self.listOfTemplate.count == 0 {
+                    
+                    let temp = NCCommunicationEditorTemplates()
+                    
+                    temp.identifier = ""
+                    if self.editorId == k_editor_text {
+                        temp.ext = "md"
+                    } else if self.editorId == k_editor_onlyoffice && self.typeTemplate == k_template_document {
+                        temp.ext = "docx"
+                    } else if self.editorId == k_editor_onlyoffice && self.typeTemplate == k_template_spreadsheet {
+                        temp.ext = "xlsx"
+                    } else if self.editorId == k_editor_onlyoffice && self.typeTemplate == k_template_presentation {
+                        temp.ext = "pptx"
                     }
                     }
+                    temp.name = "Empty"
+                    temp.preview = ""
+                                                                  
+                    self.listOfTemplate.append(temp)
                     
                     
-                    self.collectionView.reloadData()
-                                        
-                } else if errorCode != 0 {
-                    NCContentPresenter.shared.messageNotification("_error_", description: errorMessage, delay: TimeInterval(k_dismissAfterSecond), type: NCContentPresenter.messageType.error, errorCode: errorCode)
-                } else {
-                    print("[LOG] It has been changed user during networking process, error.")
+                    self.selectTemplate = temp
+                    self.fileNameExtension = temp.ext
+                    self.navigationItem.rightBarButtonItem?.isEnabled = true
                 }
                 }
+                
+                self.collectionView.reloadData()
             }
             }
             
             
         }
         }
@@ -460,6 +455,7 @@ import NCCommunication
                     for template in templates! {
                     for template in templates! {
                         
                         
                         let temp = NCCommunicationEditorTemplates()
                         let temp = NCCommunicationEditorTemplates()
+                        
                         temp.identifier = "\(template.templateId)"
                         temp.identifier = "\(template.templateId)"
                         temp.delete = template.delete
                         temp.delete = template.delete
                         temp.ext = template.ext
                         temp.ext = template.ext
@@ -476,14 +472,31 @@ import NCCommunication
                             self.navigationItem.rightBarButtonItem?.isEnabled = true
                             self.navigationItem.rightBarButtonItem?.isEnabled = true
                         }
                         }
                     }
                     }
+                }
+                
+                if self.listOfTemplate.count == 0 {
                     
                     
-                    self.collectionView.reloadData()
+                    let temp = NCCommunicationEditorTemplates()
                     
                     
-                } else if errorCode != 0 {
-                    NCContentPresenter.shared.messageNotification("_error_", description: errorDescription, delay: TimeInterval(k_dismissAfterSecond), type: NCContentPresenter.messageType.error, errorCode: errorCode)
-                } else {
-                    print("[LOG] It has been changed user during networking process, error.")
+                    temp.identifier = ""
+                    if self.typeTemplate == k_template_document {
+                        temp.ext = "docx"
+                    } else if self.typeTemplate == k_template_spreadsheet {
+                        temp.ext = "xlsx"
+                    } else if self.typeTemplate == k_template_presentation {
+                        temp.ext = "pptx"
+                    }
+                    temp.name = "Empty"
+                    temp.preview = ""
+                                                                  
+                    self.listOfTemplate.append(temp)
+                    
+                    self.selectTemplate = temp
+                    self.fileNameExtension = temp.ext
+                    self.navigationItem.rightBarButtonItem?.isEnabled = true
                 }
                 }
+                
+                self.collectionView.reloadData()
             }
             }
         }
         }
     }
     }