fix(workspace): publish loaded folder children
This commit is contained in:
parent
1801f44f86
commit
771f3368b4
1 changed files with 9 additions and 3 deletions
|
|
@ -164,19 +164,25 @@ private final class SaplingAppModel: ObservableObject {
|
||||||
guard let url = item.containerURL?.standardizedFileURL else { return }
|
guard let url = item.containerURL?.standardizedFileURL else { return }
|
||||||
guard workspaceChildren[url] == nil, !loadingTreeItemURLs.contains(url) else { return }
|
guard workspaceChildren[url] == nil, !loadingTreeItemURLs.contains(url) else { return }
|
||||||
|
|
||||||
loadingTreeItemURLs.insert(url)
|
var loadingURLs = loadingTreeItemURLs
|
||||||
|
loadingURLs.insert(url)
|
||||||
|
loadingTreeItemURLs = loadingURLs
|
||||||
let workspaceManager = self.workspaceManager
|
let workspaceManager = self.workspaceManager
|
||||||
Task {
|
Task {
|
||||||
do {
|
do {
|
||||||
let children = try await Task.detached {
|
let children = try await Task.detached {
|
||||||
try await workspaceManager.loadItems(in: url)
|
try await workspaceManager.loadItems(in: url)
|
||||||
}.value
|
}.value
|
||||||
workspaceChildren[url] = children
|
var loadedChildren = workspaceChildren
|
||||||
|
loadedChildren[url] = children
|
||||||
|
workspaceChildren = loadedChildren
|
||||||
} catch {
|
} catch {
|
||||||
editorErrorMessage = "Unable to load \(item.displayName): \(error.localizedDescription)"
|
editorErrorMessage = "Unable to load \(item.displayName): \(error.localizedDescription)"
|
||||||
logger.error("Failed to load workspace tree item: \(error)", category: .workspace)
|
logger.error("Failed to load workspace tree item: \(error)", category: .workspace)
|
||||||
}
|
}
|
||||||
loadingTreeItemURLs.remove(url)
|
var loadingURLs = loadingTreeItemURLs
|
||||||
|
loadingURLs.remove(url)
|
||||||
|
loadingTreeItemURLs = loadingURLs
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue