aboutsummaryrefslogtreecommitdiff
path: root/Hotline/State
diff options
context:
space:
mode:
authorDustin Mierau <dustin@mierau.me>2025-11-13 11:33:43 -0800
committerDustin Mierau <dustin@mierau.me>2025-11-13 11:33:43 -0800
commitda6a1f92caa31c85f9182bff4c29ceb5c72b3742 (patch)
treeca79509164efe287354ee221542a93a4919613b9 /Hotline/State
parent467b53f143a0c3d7328fe85e9d1215eceb9b150a (diff)
Don't show accounts in sidebar to reduce clutter. Admins can use menu bar or toolbar. More error handling.
Diffstat (limited to 'Hotline/State')
-rw-r--r--Hotline/State/HotlineState.swift33
1 files changed, 28 insertions, 5 deletions
diff --git a/Hotline/State/HotlineState.swift b/Hotline/State/HotlineState.swift
index 1f8e2e5..c9810ad 100644
--- a/Hotline/State/HotlineState.swift
+++ b/Hotline/State/HotlineState.swift
@@ -852,11 +852,22 @@ class HotlineState: Equatable {
throw HotlineClientError.notConnected
}
- return try await client.newFolder(name: name, path: parentPath)
+ do {
+ try await client.newFolder(name: name, path: parentPath)
+ self.invalidateFileListCache(for: parentPath, includingAncestors: true)
+ return true
+ }
+ catch let error as HotlineClientError {
+ self.errorMessage = error.userMessage
+ self.errorDisplayed = true
+ }
+
+ return false
}
+ @discardableResult
@MainActor
- func deleteFile(_ fileName: String, path: [String]) async throws {
+ func deleteFile(_ fileName: String, path: [String]) async throws -> Bool {
guard let client = self.client else {
throw HotlineClientError.notConnected
}
@@ -869,12 +880,14 @@ class HotlineState: Equatable {
do {
try await client.deleteFile(name: fileName, path: fullPath)
self.invalidateFileListCache(for: fullPath, includingAncestors: true)
+ return true
}
catch let error as HotlineClientError {
self.errorMessage = error.userMessage
self.errorDisplayed = true
- return
}
+
+ return false
}
/// Download a file from the server.
@@ -896,9 +909,19 @@ class HotlineState: Equatable {
Task { @MainActor [weak self] in
guard let self else { return }
-
+
// Request download from server
- guard let result = try? await client.downloadFile(name: fileName, path: fullPath),
+ let result: (referenceNumber: UInt32, transferSize: Int, fileSize: Int, waitingCount: Int)?
+ do {
+ result = try await client.downloadFile(name: fileName, path: fullPath)
+ }
+ catch let error as HotlineClientError {
+ self.errorMessage = error.userMessage
+ self.errorDisplayed = true
+ return
+ }
+
+ guard let result,
let server = self.server,
let address = server.address as String?,
let port = server.port as Int?