mirror of
https://github.com/usatiuk/cardboy.git
synced 2025-10-28 23:27:49 +01:00
overlay fixes
This commit is contained in:
@@ -149,6 +149,11 @@ private struct FileManagerTabView: View {
|
|||||||
manager.changeDirectory(to: target)
|
manager.changeDirectory(to: target)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.onChange(of: manager.connectionState) { newState in
|
||||||
|
if newState == .ready, !manager.isFileBusy {
|
||||||
|
manager.refreshDirectory()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -204,6 +204,10 @@ final class TimeSyncManager: NSObject, ObservableObject {
|
|||||||
// MARK: - File operations exposed to UI
|
// MARK: - File operations exposed to UI
|
||||||
|
|
||||||
func refreshDirectory() {
|
func refreshDirectory() {
|
||||||
|
if isFileBusy {
|
||||||
|
pendingDirectoryRequest = (path: currentDirectory, operationID: pendingDirectoryRequest?.operationID ?? UUID())
|
||||||
|
return
|
||||||
|
}
|
||||||
requestDirectory(path: currentDirectory)
|
requestDirectory(path: currentDirectory)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -679,32 +683,27 @@ final class TimeSyncManager: NSObject, ObservableObject {
|
|||||||
private func requestDirectory(path: String) {
|
private func requestDirectory(path: String) {
|
||||||
let normalizedPath = normalizedPath(path)
|
let normalizedPath = normalizedPath(path)
|
||||||
|
|
||||||
guard let commandCharacteristic = fileCommandCharacteristic else {
|
if let commandCharacteristic = fileCommandCharacteristic {
|
||||||
|
let opID: UUID
|
||||||
|
if let pending = pendingDirectoryRequest, pending.path == normalizedPath {
|
||||||
|
opID = pending.operationID
|
||||||
|
pendingDirectoryRequest = nil
|
||||||
|
} else {
|
||||||
|
opID = UUID()
|
||||||
|
}
|
||||||
|
startDirectoryRequest(path: normalizedPath, operationID: opID, characteristic: commandCharacteristic)
|
||||||
|
} else {
|
||||||
let opID = pendingDirectoryRequest?.operationID ?? UUID()
|
let opID = pendingDirectoryRequest?.operationID ?? UUID()
|
||||||
pendingDirectoryRequest = (path: normalizedPath, operationID: opID)
|
pendingDirectoryRequest = (path: normalizedPath, operationID: opID)
|
||||||
pendingListPath = normalizedPath
|
|
||||||
pendingListData.removeAll()
|
|
||||||
isFileBusy = true
|
|
||||||
pendingListOperationID = opID
|
|
||||||
updateOperation(id: opID, title: "Loading", message: normalizedPath, progress: nil, indeterminate: true)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
let opID: UUID
|
if connectionState == .ready {
|
||||||
if let pending = pendingDirectoryRequest, pending.path == normalizedPath {
|
pendingListPath = normalizedPath
|
||||||
opID = pending.operationID
|
pendingListData.removeAll()
|
||||||
pendingDirectoryRequest = nil
|
isFileBusy = true
|
||||||
} else {
|
pendingListOperationID = opID
|
||||||
opID = UUID()
|
updateOperation(id: opID, title: "Loading", message: normalizedPath, progress: nil, indeterminate: true)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pendingListPath = normalizedPath
|
|
||||||
pendingListData.removeAll()
|
|
||||||
isFileBusy = true
|
|
||||||
pendingListOperationID = opID
|
|
||||||
updateOperation(id: opID, title: "Loading", message: normalizedPath, progress: nil, indeterminate: true)
|
|
||||||
let payload = payloadFor(path: normalizedPath)
|
|
||||||
enqueueFileCommand(.listDirectory, payload: payload, characteristic: commandCharacteristic)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@discardableResult
|
@discardableResult
|
||||||
@@ -713,14 +712,18 @@ final class TimeSyncManager: NSObject, ObservableObject {
|
|||||||
let commandCharacteristic = fileCommandCharacteristic else { return false }
|
let commandCharacteristic = fileCommandCharacteristic else { return false }
|
||||||
|
|
||||||
pendingDirectoryRequest = nil
|
pendingDirectoryRequest = nil
|
||||||
pendingListPath = pending.path
|
startDirectoryRequest(path: pending.path, operationID: pending.operationID, characteristic: commandCharacteristic)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
private func startDirectoryRequest(path: String, operationID: UUID, characteristic: CBCharacteristic) {
|
||||||
|
pendingListPath = path
|
||||||
pendingListData.removeAll()
|
pendingListData.removeAll()
|
||||||
isFileBusy = true
|
isFileBusy = true
|
||||||
pendingListOperationID = pending.operationID
|
pendingListOperationID = operationID
|
||||||
updateOperation(id: pending.operationID, title: "Loading", message: pending.path, progress: nil, indeterminate: true)
|
updateOperation(id: operationID, title: "Loading", message: path, progress: nil, indeterminate: true)
|
||||||
let payload = payloadFor(path: pending.path)
|
let payload = payloadFor(path: path)
|
||||||
enqueueFileCommand(.listDirectory, payload: payload, characteristic: commandCharacteristic)
|
enqueueFileCommand(.listDirectory, payload: payload, characteristic: characteristic)
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user