diff options
| author | Dustin Mierau <dustin@mierau.me> | 2025-11-13 11:13:01 -0800 |
|---|---|---|
| committer | Dustin Mierau <dustin@mierau.me> | 2025-11-13 11:13:01 -0800 |
| commit | 467b53f143a0c3d7328fe85e9d1215eceb9b150a (patch) | |
| tree | e8db83720021bc9361732d06ff539fcd42d72def /Hotline/macOS/Files | |
| parent | 5818df427f045f3aa54f648a0828c8d997327fbe (diff) | |
Start surfacing server errors properly to communicate permissions better.
Diffstat (limited to 'Hotline/macOS/Files')
| -rw-r--r-- | Hotline/macOS/Files/FilesView.swift | 16 | ||||
| -rw-r--r-- | Hotline/macOS/Files/FolderItemView.swift | 4 |
2 files changed, 12 insertions, 8 deletions
diff --git a/Hotline/macOS/Files/FilesView.swift b/Hotline/macOS/Files/FilesView.swift index 2386d2a..ab93cbc 100644 --- a/Hotline/macOS/Files/FilesView.swift +++ b/Hotline/macOS/Files/FilesView.swift @@ -448,14 +448,14 @@ struct FilesView: View { @MainActor private func downloadFile(_ file: FileInfo) { if file.isFolder { - model.downloadFolder(file.name, path: file.path) + self.model.downloadFolder(file.name, path: file.path) } else { - model.downloadFile(file.name, path: file.path) + self.model.downloadFile(file.name, path: file.path) } } - @MainActor private func uploadFile(file fileURL: URL, to path: [String]) { + @MainActor private func uploadFile(file fileURL: URL, to path: [String]) throws { self.model.uploadFile(url: fileURL, path: path) { info in Task { // Refresh file listing to display newly uploaded file. @@ -508,9 +508,13 @@ struct FilesView: View { if file.path.count > 1 { parentPath = Array(file.path[0..<file.path.count-1]) } - - if (try? await model.deleteFile(file.name, path: file.path)) == true { - let _ = try? await model.getFileList(path: parentPath) + + do { + try await self.model.deleteFile(file.name, path: file.path) + try await self.model.getFileList(path: parentPath) + } + catch { + print("Error deleting file: \(error)") } } } diff --git a/Hotline/macOS/Files/FolderItemView.swift b/Hotline/macOS/Files/FolderItemView.swift index 9b13cc0..18522af 100644 --- a/Hotline/macOS/Files/FolderItemView.swift +++ b/Hotline/macOS/Files/FolderItemView.swift @@ -17,7 +17,7 @@ struct FolderItemView: View { print("UPLOADING TO PATH: ", filePath) - model.uploadFile(url: fileURL, path: filePath) { info in + self.model.uploadFile(url: fileURL, path: filePath) { info in Task { // Refresh file listing to display newly uploaded file. let _ = try? await model.getFileList(path: filePath) @@ -118,7 +118,7 @@ struct FolderItemView: View { DispatchQueue.main.async { if let urlData = urlData as? Data, let fileURL = URL(dataRepresentation: urlData, relativeTo: nil, isAbsolute: true) { - uploadFile(file: fileURL) + self.uploadFile(file: fileURL) } } } |