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/Hotline/HotlineClient.swift | 9 +++ Hotline/Models/Hotline.swift | 72 ++++++---------------- Hotline/macOS/FilesView.swift | 115 +++++++++++++++++++++++++++++------- Hotline/macOS/NewsView.swift | 15 ++++- 4 files changed, 133 insertions(+), 78 deletions(-) (limited to 'Hotline') diff --git a/Hotline/Hotline/HotlineClient.swift b/Hotline/Hotline/HotlineClient.swift index 1c72ab0..b30ee11 100644 --- a/Hotline/Hotline/HotlineClient.swift +++ b/Hotline/Hotline/HotlineClient.swift @@ -628,6 +628,15 @@ class HotlineClient: NetSocketDelegate { } } + @MainActor func sendDeleteFile(name fileName: String, path filePath: [String], callback: ((Bool) -> Void)? = nil) { + var t = HotlineTransaction(type: .deleteFile) + t.setFieldString(type: .fileName, val: fileName) + t.setFieldPath(type: .filePath, val: filePath) + self.sendPacket(t) { reply, err in + callback?(err == nil) + } + } + @MainActor func sendGetFileInfo(name fileName: String, path filePath: [String], callback: ((FileDetails?) -> Void)? = nil) { var t = HotlineTransaction(type: .getFileInfo) t.setFieldString(type: .fileName, val: fileName) diff --git a/Hotline/Models/Hotline.swift b/Hotline/Models/Hotline.swift index 06baf04..ce917cd 100644 --- a/Hotline/Models/Hotline.swift +++ b/Hotline/Models/Hotline.swift @@ -545,14 +545,29 @@ class Hotline: Equatable, HotlineClientDelegate, HotlineFileClientDelegate { } } - @MainActor func fileDetails(_ fileName: String, path: [String], complete callback: ((FileDetails?) -> Void)? = nil) { + @MainActor func getFileDetails(_ fileName: String, path: [String]) async -> FileDetails? { var fullPath: [String] = [] if path.count > 1 { fullPath = Array(path[0.. Bool { + var fullPath: [String] = [] + if path.count > 1 { + fullPath = Array(path[0.. Void)? = nil) { -// var fullPath: [String] = [] -// if path.count > 1 { -// fullPath = Array(path[0.. 1 { + parentPath = Array(file.path[0..