From 4464f7e460a238c563b9b3f460034314c5f22cc2 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Sat, 6 Apr 2024 22:11:29 +0800 Subject: [PATCH] Simplify configuration of text field delegate Signed-off-by: Claudio Cambra --- .../FileProviderUIExt/ShareOptionsView.swift | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift index 893d6bb3c..d3f41c79c 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift @@ -42,13 +42,16 @@ class ShareOptionsView: NSView { Logger.shareOptionsView.error("Could not configure suggestions data source.") return } - suggestionsWindowController.dataSource = ShareeSuggestionsDataSource(kit: kit) - suggestionsWindowController.parentTextField = shareRecipientTextField - suggestionsTextFieldDelegate.suggestionsWindowController = suggestionsWindowController - shareRecipientTextField.delegate = suggestionsTextFieldDelegate - - suggestionsWindowController.begin(for: shareRecipientTextField) + suggestionsTextFieldDelegate.suggestionsDataSource = ShareeSuggestionsDataSource( + kit: kit + ) + suggestionsTextFieldDelegate.confirmationHandler = { suggestion in + guard let sharee = suggestion?.data as? NKSharee else { return } + self.shareRecipientTextField.stringValue = sharee.shareWith + Logger.shareOptionsView.debug("Chose sharee \(sharee.shareWith, privacy: .public)") + } + suggestionsTextFieldDelegate.targetTextField = shareRecipientTextField } } var dataSource: ShareTableViewDataSource?