Skip to content

Commit 4e1f8bc

Browse files
committed
refactor(ModernEntryEditorView): update file selection to use async Task with @mainactor
1 parent 68e0425 commit 4e1f8bc

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

ConfigForge/Views/Editors/ModernEntryEditorView.swift

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -252,11 +252,10 @@ struct ModernEntryEditorView: View {
252252
openPanel.allowsMultipleSelection = false
253253
openPanel.allowedContentTypes = [.text, .data] // Allow common key file types
254254

255-
openPanel.begin { (result) in
256-
if result == .OK, let url = openPanel.url {
257-
DispatchQueue.main.async {
258-
// Ensure index is still valid before updating, though less likely an issue here
259-
if editedDirectives.indices.contains(index) {
255+
openPanel.begin { result in
256+
if result == .OK {
257+
Task { @MainActor in
258+
if let url = openPanel.url, editedDirectives.indices.contains(index) {
260259
editedDirectives[index].value = url.path
261260
print("Selected file path for directive at index \(index): \(url.path)")
262261
}
@@ -444,4 +443,4 @@ struct ModernEntryEditorView: View {
444443
private func addAdvancedDirective() {
445444
editedDirectives.append((key: "", value: ""))
446445
}
447-
}
446+
}

0 commit comments

Comments
 (0)