ClientListMgr // Autofill recent 20 clients on adding new clients.

This commit is contained in:
ShikiSuen 2023-02-18 22:53:38 +08:00
parent bb991d0c86
commit 1f3fd08cad
1 changed files with 9 additions and 1 deletions

View File

@ -97,12 +97,20 @@ extension CtlClientListMgr {
theTextView.textContainer?.containerSize = NSSize(width: maxFloat, height: maxFloat)
theTextView.textContainer?.widthTracksTextView = false
//
theTextView.textContainer?.textView?.string = {
let recentClients = SessionCtl.recentClientBundleIdentifiers.keys.compactMap {
PrefMgr.shared.clientsIMKTextInputIncapable.keys.contains($0) ? nil : $0
}
return recentClients.sorted().joined(separator: "\n")
}()
alert.accessoryView = scrollview
alert.beginSheetModal(for: window) { result in
switch result {
case .alertFirstButtonReturn, .alertSecondButtonReturn:
theTextView.textContainer?.textView?.string.components(separatedBy: "\n").filter { !$0.isEmpty }.forEach {
self.applyNewValue($0)
self.applyNewValue($0, highMitigation: result == .alertFirstButtonReturn)
}
if result == .alertFirstButtonReturn { break }
let dlgOpenPath = NSOpenPanel()