Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to edit/delete files within subdirectories #58

Open
Emperor-Koala opened this issue Mar 4, 2019 · 2 comments
Open

Unable to edit/delete files within subdirectories #58

Emperor-Koala opened this issue Mar 4, 2019 · 2 comments

Comments

@Emperor-Koala
Copy link

When I import this project, I can use it and everything works (mostly) as expected. My only issue is that I can't delete anything if its in a subdirectory to the initial directory. Is this a bug, or is there some sort of easy fix?

I've been scratching my head for about an hour, and I tried adding fileListViewController.allowEditing = allowEditing to the function tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath), but it doesn't appear to work the way I was hoping.

@Emperor-Koala
Copy link
Author

The strange thing here is that I got this to work in the simulator, but it still doesn't work on my actual device.

@rlegault33
Copy link

rlegault33 commented Dec 5, 2020

To fix the delete to propagate down to the subdirectory files you need to add the line
fileListViewController.allowEditing = self.allowEditing
at line 48 in FileListTableView.swift
This will allow it to propagate into the subdirectory.

Here is the full function in that file with the added line

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
    let selectedFile = fileForIndexPath(indexPath)
    searchController.isActive = false
    if selectedFile.isDirectory {
        let fileListViewController = FileListViewController(initialPath: selectedFile.filePath)
        fileListViewController.didSelectFile = didSelectFile

// Here is the fix ----
        fileListViewController.allowEditing = self.allowEditing

        self.navigationController?.pushViewController(fileListViewController, animated: true)
    }
    else {
        if let didSelectFile = didSelectFile {
            self.dismiss()
            didSelectFile(selectedFile)
        }
        else {
            let filePreview = previewManager.previewViewControllerForFile(selectedFile, fromNavigation: true)
            self.navigationController?.pushViewController(filePreview, animated: true)
        }
    }
    tableView.deselectRow(at: indexPath, animated: true)
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants