Associate and handle imported files (#628)
This commit is contained in:
parent
95c09f4353
commit
9e6e59276b
|
@ -32,8 +32,7 @@
|
|||
<string>Alternate</string>
|
||||
<key>LSItemContentTypes</key>
|
||||
<array>
|
||||
<string>public.text</string>
|
||||
<string>public.zip-archive</string>
|
||||
<string>public.item</string>
|
||||
</array>
|
||||
</dict>
|
||||
<dict>
|
||||
|
|
|
@ -42,11 +42,13 @@ struct PassepartoutApp: App {
|
|||
private let context: AppContext = .shared
|
||||
// private let context: AppContext = .mock(withRegistry: .shared)
|
||||
|
||||
private let appName = Constants.shared.identifiers.displayName
|
||||
|
||||
@StateObject
|
||||
private var theme = Theme()
|
||||
|
||||
var body: some Scene {
|
||||
WindowGroup {
|
||||
Window(appName, id: appName) {
|
||||
AppCoordinator(
|
||||
profileManager: context.profileManager,
|
||||
tunnel: context.tunnel,
|
||||
|
|
|
@ -47,8 +47,11 @@ struct ProfileImporterModifier: ViewModifier {
|
|||
isPresented: $isPresented,
|
||||
allowedContentTypes: [.item],
|
||||
allowsMultipleSelection: true,
|
||||
onCompletion: onCompletion
|
||||
onCompletion: handleResult
|
||||
)
|
||||
.onOpenURL { url in
|
||||
handleResult(.success([url]))
|
||||
}
|
||||
.alert(
|
||||
Strings.Views.Profiles.Toolbar.importProfile,
|
||||
isPresented: $importer.isPresentingPassphrase,
|
||||
|
@ -85,7 +88,7 @@ private extension ProfileImporterModifier {
|
|||
Text(Strings.Views.Profiles.Alerts.Import.Passphrase.message(url.lastPathComponent))
|
||||
}
|
||||
|
||||
func onCompletion(_ result: Result<[URL], Error>) {
|
||||
func handleResult(_ result: Result<[URL], Error>) {
|
||||
Task.detached {
|
||||
do {
|
||||
let urls = try result.get()
|
||||
|
|
Loading…
Reference in New Issue