Simplify configuration of text field delegate

Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
This commit is contained in:
Claudio Cambra 2024-04-06 22:11:29 +08:00
parent 66f77233a8
commit 4464f7e460

View file

@ -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?