Преглед изворни кода

unconditionally open document picker for backup selection

cyberta пре 2 година
родитељ
комит
10aaa2db78
1 измењених фајлова са 4 додато и 32 уклоњено
  1. 4 32
      deltachat-ios/Controller/WelcomeViewController.swift

+ 4 - 32
deltachat-ios/Controller/WelcomeViewController.swift

@@ -277,14 +277,7 @@ class WelcomeViewController: UIViewController, ProgressAlertHandler {
         if dcContext.isConfigured() {
             return
         }
-        addProgressHudBackupListener()
-
-        if let documentsDirectory = ensureDcDocFolderExists(),
-           let filePath = dcContext.imexHasBackup(filePath: documentsDirectory.relativePath) {
-            importBackup(at: filePath)
-        } else {
-            mediaPicker?.showDocumentLibrary(selectFolder: true)
-        }
+        mediaPicker?.showDocumentLibrary(selectFolder: true)
     }
 
     private func importBackup(at filepath: String) {
@@ -294,20 +287,6 @@ class WelcomeViewController: UIViewController, ProgressAlertHandler {
         dcContext.imex(what: DC_IMEX_IMPORT_BACKUP, directory: filepath)
     }
 
-    private func ensureDcDocFolderExists() -> URL? {
-        let fileManager = FileManager.default
-        guard let documentsDirectory = try? fileManager.url(for: .documentDirectory,
-                                                            in: .userDomainMask,
-                                                            appropriateFor: nil,
-                                                            create: true) else { return nil }
-
-        let emptyHiddenFileURL = documentsDirectory.appendingPathComponent(".Move your backup here")
-        if !fileManager.fileExists(atPath: emptyHiddenFileURL.relativePath) {
-            fileManager.createFile(atPath: emptyHiddenFileURL.relativePath, contents: nil)
-        }
-        return documentsDirectory
-    }
-
     private func addProgressHudBackupListener() {
         let nc = NotificationCenter.default
         backupProgressObserver = nc.addObserver(
@@ -601,21 +580,14 @@ extension WelcomeViewController: MediaPickerDelegate {
         }
 
         if let selectedBackupFilePath = url.relativePath {
-             importBackup(at: selectedBackupFilePath)
+            addProgressHudBackupListener()
+            importBackup(at: selectedBackupFilePath)
         } else {
             onSelectionCancelled()
-            securityScopedResource = nil
         }
     }
 
     func onSelectionCancelled() {
-        let alert = UIAlertController(
-            title: String.localized("import_backup_title"),
-            message: String.localizedStringWithFormat(
-                String.localized("import_backup_no_backup_found"),
-                "➔ Mac-Finder or iTunes ➔ iPhone ➔ " + String.localized("files") + " ➔ Delta Chat"), // iTunes was used up to Maverick 10.4
-            preferredStyle: .alert)
-        alert.addAction(UIAlertAction(title: String.localized("ok"), style: .cancel))
-        present(alert, animated: true)
+        securityScopedResource = nil
     }
 }