aboutsummaryrefslogtreecommitdiff
path: root/Hotline/State/HotlineState.swift
diff options
context:
space:
mode:
Diffstat (limited to 'Hotline/State/HotlineState.swift')
-rw-r--r--Hotline/State/HotlineState.swift30
1 files changed, 20 insertions, 10 deletions
diff --git a/Hotline/State/HotlineState.swift b/Hotline/State/HotlineState.swift
index c9810ad..c632f91 100644
--- a/Hotline/State/HotlineState.swift
+++ b/Hotline/State/HotlineState.swift
@@ -789,7 +789,6 @@ class HotlineState: Equatable {
// MARK: - Users
- @MainActor
func getUserList() async throws {
guard let client = self.client else {
throw HotlineClientError.notConnected
@@ -801,7 +800,6 @@ class HotlineState: Equatable {
// MARK: - Files
- @MainActor
@discardableResult
func getFileList(path: [String] = [], suppressErrors: Bool = false, preferCache: Bool = false) async throws -> [FileInfo] {
guard let client = self.client else {
@@ -832,7 +830,6 @@ class HotlineState: Equatable {
return newFiles
}
- @MainActor
func getFileDetails(_ fileName: String, path: [String]) async throws -> FileDetails? {
guard let client = self.client else {
throw HotlineClientError.notConnected
@@ -846,7 +843,26 @@ class HotlineState: Equatable {
return try await client.getFileInfo(name: fileName, path: fullPath)
}
- @MainActor
+ @discardableResult
+ func setFileInfo(fileName: String, path filePath: [String], fileNewName: String?, comment: String?) async throws -> Bool {
+ guard let client = self.client else {
+ throw HotlineClientError.notConnected
+ }
+
+ do {
+ try await client.setFileInfo(name: fileName, path: filePath, newName: fileNewName, comment: comment)
+ self.invalidateFileListCache(for: filePath, includingAncestors: true)
+ return true
+ }
+ catch let error as HotlineClientError {
+ self.errorMessage = error.userMessage
+ self.errorDisplayed = true
+ }
+
+ return false
+ }
+
+ @discardableResult
func newFolder(name: String, parentPath: [String]) async throws -> Bool {
guard let client = self.client else {
throw HotlineClientError.notConnected
@@ -1404,12 +1420,6 @@ class HotlineState: Equatable {
}
}
- func setFileInfo(fileName: String, path filePath: [String], fileNewName: String?, comment: String?, encoding: String.Encoding = .utf8) {
- // TODO: Implement setFileInfo in HotlineClient
- // This method updates file metadata (name and/or comment)
- print("setFileInfo not yet implemented in HotlineState/HotlineClient")
- }
-
@MainActor
func previewFile(_ fileName: String, path: [String], complete callback: ((PreviewFileInfo?) -> Void)? = nil) {
guard let client = self.client else {