Skip to content

Commit

Permalink
home(macOS): support importing multiple .utm files
Browse files Browse the repository at this point in the history
Resolves #3685
  • Loading branch information
osy committed Feb 26, 2022
1 parent 970bc63 commit 4a67328
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions Platform/Shared/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ struct ContentView: View {
data.newVM()
}.onReceive(NSNotification.ImportVirtualMachine) { _ in
importSheetPresented = true
}.fileImporter(isPresented: $importSheetPresented, allowedContentTypes: [.UTM], onCompletion: selectImportedUTM)
}.fileImporter(isPresented: $importSheetPresented, allowedContentTypes: [.UTM], allowsMultipleSelection: true, onCompletion: selectImportedUTM)
.onAppear {
Task {
await data.listRefresh()
Expand Down Expand Up @@ -158,10 +158,12 @@ struct ContentView: View {
try await data.importUTM(from: url)
}

private func selectImportedUTM(result: Result<URL, Error>) {
private func selectImportedUTM(result: Result<[URL], Error>) {
data.busyWorkAsync {
let url = try result.get()
try await data.importUTM(from: url)
let urls = try result.get()
for url in urls {
try await data.importUTM(from: url)
}
}
}

Expand Down

0 comments on commit 4a67328

Please sign in to comment.