Alert the user the first time they try to copy URLs from articles where some have no URLs

This commit is contained in:
Nate Weaver
2022-10-10 16:43:36 -05:00
parent 3cd295bbb1
commit cdf2dd5d64
5 changed files with 60 additions and 11 deletions

View File

@@ -330,7 +330,7 @@ class MainWindowController : NSWindowController, NSUserInterfaceValidations {
@IBAction func copyArticleURL(_ sender: Any?) {
if let currentLinks {
URLPasteboardWriter.write(urlStrings: currentLinks, to: .general)
URLPasteboardWriter.write(urlStrings: currentLinks, alertingInWindow: window)
}
}
@@ -1071,8 +1071,8 @@ private extension MainWindowController {
return selectedArticles?.first { $0.preferredLink != nil }?.preferredLink
}
var currentLinks: [String]? {
return selectedArticles?.compactMap { $0.preferredLink }
var currentLinks: [String?]? {
return selectedArticles?.map { $0.preferredLink }
}
// MARK: - State Restoration
@@ -1110,7 +1110,11 @@ private extension MainWindowController {
// MARK: - Command Validation
func canCopyArticleURL() -> Bool {
return currentLinks != nil
if let currentLinks, currentLinks.count != 0 {
return true
}
return false
}
func canCopyExternalURL() -> Bool {