From ac3c8f540751e4138319d9e4e7ffb92a9b2236e2 Mon Sep 17 00:00:00 2001 From: Dustin Mierau Date: Tue, 14 May 2024 18:12:56 -0700 Subject: Some contextual menus in files and newsgroups. Added functional delete file context menu. --- Hotline/macOS/FilesView.swift | 115 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 94 insertions(+), 21 deletions(-) (limited to 'Hotline/macOS/FilesView.swift') diff --git a/Hotline/macOS/FilesView.swift b/Hotline/macOS/FilesView.swift index a225549..77db291 100644 --- a/Hotline/macOS/FilesView.swift +++ b/Hotline/macOS/FilesView.swift @@ -127,12 +127,51 @@ struct FilesView: View { // let _ = FilePreviewWindowController(info: previewInfo) } + @MainActor private func getFileInfo(_ file: FileInfo) { + Task { + if let fileInfo = await model.getFileDetails(file.name, path: file.path) { + Task { @MainActor in + self.fileDetails = fileInfo + } + } + } + } + + @MainActor private func downloadFile(_ file: FileInfo) { + guard !file.isFolder else { + return + } + + model.downloadFile(file.name, path: file.path) + } + + @MainActor private func previewFile(_ file: FileInfo) { + guard file.isPreviewable else { + return + } + + model.previewFile(file.name, path: file.path) { info in + if let info = info { + openPreviewWindow(info) + } + } + } + + private func deleteFile(_ file: FileInfo) async { + var parentPath: [String] = [] + if file.path.count > 1 { + parentPath = Array(file.path[0..