mirror of
https://github.com/usatiuk/cardboy.git
synced 2025-10-28 15:17:48 +01:00
overlay fixes
This commit is contained in:
@@ -149,6 +149,11 @@ private struct FileManagerTabView: View {
|
||||
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
|
||||
|
||||
func refreshDirectory() {
|
||||
if isFileBusy {
|
||||
pendingDirectoryRequest = (path: currentDirectory, operationID: pendingDirectoryRequest?.operationID ?? UUID())
|
||||
return
|
||||
}
|
||||
requestDirectory(path: currentDirectory)
|
||||
}
|
||||
|
||||
@@ -679,32 +683,27 @@ final class TimeSyncManager: NSObject, ObservableObject {
|
||||
private func requestDirectory(path: String) {
|
||||
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()
|
||||
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 let pending = pendingDirectoryRequest, pending.path == normalizedPath {
|
||||
opID = pending.operationID
|
||||
pendingDirectoryRequest = nil
|
||||
} else {
|
||||
opID = UUID()
|
||||
if connectionState == .ready {
|
||||
pendingListPath = normalizedPath
|
||||
pendingListData.removeAll()
|
||||
isFileBusy = true
|
||||
pendingListOperationID = opID
|
||||
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
|
||||
@@ -713,14 +712,18 @@ final class TimeSyncManager: NSObject, ObservableObject {
|
||||
let commandCharacteristic = fileCommandCharacteristic else { return false }
|
||||
|
||||
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()
|
||||
isFileBusy = true
|
||||
pendingListOperationID = pending.operationID
|
||||
updateOperation(id: pending.operationID, title: "Loading", message: pending.path, progress: nil, indeterminate: true)
|
||||
let payload = payloadFor(path: pending.path)
|
||||
enqueueFileCommand(.listDirectory, payload: payload, characteristic: commandCharacteristic)
|
||||
return true
|
||||
pendingListOperationID = operationID
|
||||
updateOperation(id: operationID, title: "Loading", message: path, progress: nil, indeterminate: true)
|
||||
let payload = payloadFor(path: path)
|
||||
enqueueFileCommand(.listDirectory, payload: payload, characteristic: characteristic)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user