mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
Fix lint issues.
This commit is contained in:
@@ -13,16 +13,16 @@ import RSCore
|
||||
|
||||
@objc(ScriptableAccount)
|
||||
class ScriptableAccount: NSObject, UniqueIdScriptingObject, ScriptingObjectContainer {
|
||||
|
||||
let account:Account
|
||||
init (_ account:Account) {
|
||||
|
||||
let account: Account
|
||||
init (_ account: Account) {
|
||||
self.account = account
|
||||
}
|
||||
|
||||
|
||||
@objc(objectSpecifier)
|
||||
override var objectSpecifier: NSScriptObjectSpecifier? {
|
||||
let myContainer = NSApplication.shared
|
||||
let scriptObjectSpecifier = myContainer.makeFormUniqueIDScriptObjectSpecifier(forObject:self)
|
||||
let scriptObjectSpecifier = myContainer.makeFormUniqueIDScriptObjectSpecifier(forObject: self)
|
||||
return (scriptObjectSpecifier)
|
||||
}
|
||||
|
||||
@@ -47,91 +47,91 @@ class ScriptableAccount: NSObject, UniqueIdScriptingObject, ScriptingObjectConta
|
||||
}
|
||||
|
||||
// MARK: --- ScriptingObject protocol ---
|
||||
|
||||
|
||||
var scriptingKey: String {
|
||||
return "accounts"
|
||||
}
|
||||
|
||||
// MARK: --- UniqueIdScriptingObject protocol ---
|
||||
|
||||
|
||||
// I am not sure if account should prefer to be specified by name or by ID
|
||||
// but in either case it seems like the accountID would be used as the keydata, so I chose ID
|
||||
@objc(uniqueId)
|
||||
var scriptingUniqueId:Any {
|
||||
var scriptingUniqueId: Any {
|
||||
return account.accountID
|
||||
}
|
||||
|
||||
// MARK: --- ScriptingObjectContainer protocol ---
|
||||
|
||||
|
||||
var scriptingClassDescription: NSScriptClassDescription {
|
||||
return self.classDescription as! NSScriptClassDescription
|
||||
}
|
||||
|
||||
func deleteElement(_ element:ScriptingObject) {
|
||||
|
||||
func deleteElement(_ element: ScriptingObject) {
|
||||
if let scriptableFolder = element as? ScriptableFolder {
|
||||
BatchUpdate.shared.perform {
|
||||
account.removeFolder(scriptableFolder.folder) { result in
|
||||
account.removeFolder(scriptableFolder.folder) { _ in
|
||||
}
|
||||
}
|
||||
} else if let scriptableFeed = element as? ScriptableFeed {
|
||||
BatchUpdate.shared.perform {
|
||||
var container: Container? = nil
|
||||
var container: Container?
|
||||
if let scriptableFolder = scriptableFeed.container as? ScriptableFolder {
|
||||
container = scriptableFolder.folder
|
||||
} else {
|
||||
container = account
|
||||
}
|
||||
account.removeFeed(scriptableFeed.feed, from: container!) { result in
|
||||
account.removeFeed(scriptableFeed.feed, from: container!) { _ in
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@objc(isLocationRequiredToCreateForKey:)
|
||||
func isLocationRequiredToCreate(forKey key:String) -> Bool {
|
||||
return false;
|
||||
func isLocationRequiredToCreate(forKey key: String) -> Bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// MARK: --- Scriptable elements ---
|
||||
|
||||
|
||||
@objc(feeds)
|
||||
var feeds:NSArray {
|
||||
return account.topLevelFeeds.map { ScriptableFeed($0, container:self) } as NSArray
|
||||
var feeds: NSArray {
|
||||
return account.topLevelFeeds.map { ScriptableFeed($0, container: self) } as NSArray
|
||||
}
|
||||
|
||||
|
||||
@objc(valueInFeedsWithUniqueID:)
|
||||
func valueInFeeds(withUniqueID id:String) -> ScriptableFeed? {
|
||||
func valueInFeeds(withUniqueID id: String) -> ScriptableFeed? {
|
||||
guard let feed = account.existingFeed(withFeedID: id) else { return nil }
|
||||
return ScriptableFeed(feed, container:self)
|
||||
return ScriptableFeed(feed, container: self)
|
||||
}
|
||||
|
||||
|
||||
@objc(valueInFeedsWithName:)
|
||||
func valueInFeeds(withName name:String) -> ScriptableFeed? {
|
||||
func valueInFeeds(withName name: String) -> ScriptableFeed? {
|
||||
let feeds = Array(account.flattenedFeeds())
|
||||
guard let feed = feeds.first(where:{$0.name == name}) else { return nil }
|
||||
return ScriptableFeed(feed, container:self)
|
||||
guard let feed = feeds.first(where: {$0.name == name}) else { return nil }
|
||||
return ScriptableFeed(feed, container: self)
|
||||
}
|
||||
|
||||
@objc(folders)
|
||||
var folders:NSArray {
|
||||
var folders: NSArray {
|
||||
let foldersSet = account.folders ?? Set<Folder>()
|
||||
let folders = Array(foldersSet)
|
||||
return folders.map { ScriptableFolder($0, container:self) } as NSArray
|
||||
return folders.map { ScriptableFolder($0, container: self) } as NSArray
|
||||
}
|
||||
|
||||
|
||||
@objc(valueInFoldersWithUniqueID:)
|
||||
func valueInFolders(withUniqueID id:NSNumber) -> ScriptableFolder? {
|
||||
func valueInFolders(withUniqueID id: NSNumber) -> ScriptableFolder? {
|
||||
let folderId = id.intValue
|
||||
let foldersSet = account.folders ?? Set<Folder>()
|
||||
let folders = Array(foldersSet)
|
||||
guard let folder = folders.first(where:{$0.folderID == folderId}) else { return nil }
|
||||
return ScriptableFolder(folder, container:self)
|
||||
}
|
||||
guard let folder = folders.first(where: {$0.folderID == folderId}) else { return nil }
|
||||
return ScriptableFolder(folder, container: self)
|
||||
}
|
||||
|
||||
// MARK: --- Scriptable properties ---
|
||||
|
||||
@objc(allFeeds)
|
||||
var allFeeds: NSArray {
|
||||
var allFeeds: NSArray {
|
||||
var feeds = [ScriptableFeed]()
|
||||
for feed in account.topLevelFeeds {
|
||||
feeds.append(ScriptableFeed(feed, container: self))
|
||||
@@ -148,13 +148,13 @@ class ScriptableAccount: NSObject, UniqueIdScriptingObject, ScriptingObjectConta
|
||||
}
|
||||
|
||||
@objc(opmlRepresentation)
|
||||
var opmlRepresentation:String {
|
||||
return self.account.OPMLString(indentLevel:0)
|
||||
var opmlRepresentation: String {
|
||||
return self.account.OPMLString(indentLevel: 0)
|
||||
}
|
||||
|
||||
@objc(accountType)
|
||||
var accountType:OSType {
|
||||
var osType:String = ""
|
||||
var accountType: OSType {
|
||||
var osType: String = ""
|
||||
switch self.account.type {
|
||||
case .onMyMac:
|
||||
osType = "Locl"
|
||||
|
||||
@@ -25,19 +25,19 @@ protocol AppDelegateAppleEvents {
|
||||
}
|
||||
|
||||
protocol ScriptingAppDelegate {
|
||||
var scriptingCurrentArticle: Article? {get}
|
||||
var scriptingSelectedArticles: [Article] {get}
|
||||
var scriptingMainWindowController:ScriptingMainWindowController? {get}
|
||||
var scriptingCurrentArticle: Article? {get}
|
||||
var scriptingSelectedArticles: [Article] {get}
|
||||
var scriptingMainWindowController: ScriptingMainWindowController? {get}
|
||||
}
|
||||
|
||||
extension AppDelegate : AppDelegateAppleEvents {
|
||||
|
||||
extension AppDelegate: AppDelegateAppleEvents {
|
||||
|
||||
// MARK: GetURL Apple Event
|
||||
|
||||
func installAppleEventHandlers() {
|
||||
NSAppleEventManager.shared().setEventHandler(self, andSelector: #selector(AppDelegate.getURL(_:_:)), forEventClass: AEEventClass(kInternetEventClass), andEventID: AEEventID(kAEGetURL))
|
||||
}
|
||||
|
||||
|
||||
@objc func getURL(_ event: NSAppleEventDescriptor, _ withReplyEvent: NSAppleEventDescriptor) {
|
||||
|
||||
guard var urlString = event.paramDescriptor(forKeyword: keyDirectObject)?.stringValue else {
|
||||
@@ -51,14 +51,14 @@ extension AppDelegate : AppDelegateAppleEvents {
|
||||
let themeURLString = queryItems.first(where: { $0.name == "url" })?.value else {
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
if let themeURL = URL(string: themeURLString) {
|
||||
let request = URLRequest(url: themeURL)
|
||||
let task = URLSession.shared.downloadTask(with: request) { location, response, error in
|
||||
let task = URLSession.shared.downloadTask(with: request) { location, _, error in
|
||||
guard let location = location else {
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
do {
|
||||
try ArticleThemeDownloader.shared.handleFile(at: location)
|
||||
} catch {
|
||||
@@ -68,10 +68,9 @@ extension AppDelegate : AppDelegateAppleEvents {
|
||||
task.resume()
|
||||
}
|
||||
return
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Special case URL with specific scheme handler x-netnewswire-feed: intended to ensure we open
|
||||
// it regardless of which news reader may be set as the default
|
||||
let nnwScheme = "x-netnewswire-feed:"
|
||||
@@ -91,13 +90,13 @@ extension AppDelegate : AppDelegateAppleEvents {
|
||||
}
|
||||
}
|
||||
|
||||
class NetNewsWireCreateElementCommand : NSCreateCommand {
|
||||
class NetNewsWireCreateElementCommand: NSCreateCommand {
|
||||
override func performDefaultImplementation() -> Any? {
|
||||
let classDescription = self.createClassDescription
|
||||
if (classDescription.className == "feed") {
|
||||
return ScriptableFeed.handleCreateElement(command:self)
|
||||
} else if (classDescription.className == "folder") {
|
||||
return ScriptableFolder.handleCreateElement(command:self)
|
||||
if classDescription.className == "feed" {
|
||||
return ScriptableFeed.handleCreateElement(command: self)
|
||||
} else if classDescription.className == "folder" {
|
||||
return ScriptableFolder.handleCreateElement(command: self)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -111,7 +110,7 @@ class NetNewsWireCreateElementCommand : NSCreateCommand {
|
||||
is ambiguity about whether specifiers are lists or single objects, the code switches
|
||||
based on which it is.
|
||||
*/
|
||||
class NetNewsWireDeleteCommand : NSDeleteCommand {
|
||||
class NetNewsWireDeleteCommand: NSDeleteCommand {
|
||||
|
||||
/*
|
||||
delete(objectToDelete:, from container:)
|
||||
@@ -119,16 +118,16 @@ class NetNewsWireDeleteCommand : NSDeleteCommand {
|
||||
Here the code unravels the case of objectToDelete being a list or a single object,
|
||||
ultimately calling container.deleteElement(element) for each element to delete
|
||||
*/
|
||||
func delete(objectToDelete:Any, from container:ScriptingObjectContainer) {
|
||||
func delete(objectToDelete: Any, from container: ScriptingObjectContainer) {
|
||||
if let objectList = objectToDelete as? [Any] {
|
||||
for nthObject in objectList {
|
||||
self.delete(objectToDelete:nthObject, from:container)
|
||||
self.delete(objectToDelete: nthObject, from: container)
|
||||
}
|
||||
} else if let element = objectToDelete as? ScriptingObject {
|
||||
container.deleteElement(element)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
delete(specifier:, from container:)
|
||||
At this point in handling the command, the container could be a list or a single object,
|
||||
@@ -138,14 +137,14 @@ class NetNewsWireDeleteCommand : NSDeleteCommand {
|
||||
After resolving, we call delete(objectToDelete:, from container:) with the container and
|
||||
the resolved objects
|
||||
*/
|
||||
func delete(specifier:NSScriptObjectSpecifier, from container:Any) {
|
||||
func delete(specifier: NSScriptObjectSpecifier, from container: Any) {
|
||||
if let containerList = container as? [Any] {
|
||||
for nthObject in containerList {
|
||||
self.delete(specifier:specifier, from:nthObject)
|
||||
self.delete(specifier: specifier, from: nthObject)
|
||||
}
|
||||
} else if let container = container as? ScriptingObjectContainer {
|
||||
if let resolvedObjects = specifier.objectsByEvaluating(withContainers:container) {
|
||||
self.delete(objectToDelete:resolvedObjects, from:container)
|
||||
if let resolvedObjects = specifier.objectsByEvaluating(withContainers: container) {
|
||||
self.delete(objectToDelete: resolvedObjects, from: container)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -159,14 +158,14 @@ class NetNewsWireDeleteCommand : NSDeleteCommand {
|
||||
override func performDefaultImplementation() -> Any? {
|
||||
if let receiversSpecifier = self.receiversSpecifier {
|
||||
if let receiverObjects = receiversSpecifier.objectsByEvaluatingSpecifier {
|
||||
self.delete(specifier:self.keySpecifier, from:receiverObjects)
|
||||
}
|
||||
self.delete(specifier: self.keySpecifier, from: receiverObjects)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
class NetNewsWireExistsCommand : NSExistsCommand {
|
||||
class NetNewsWireExistsCommand: NSExistsCommand {
|
||||
|
||||
// cocoa default behavior doesn't work here, because of cases where we define an object's property
|
||||
// to be another object type. e.g., 'permalink of the current article' parses as
|
||||
@@ -177,10 +176,9 @@ class NetNewsWireExistsCommand : NSExistsCommand {
|
||||
// must not exist. Otherwise, we return the result of the defaultImplementation
|
||||
// The wrinkle is that it is possible that the direct object is a list, so we need to
|
||||
// handle that case as well
|
||||
|
||||
|
||||
override func performDefaultImplementation() -> Any? {
|
||||
guard let result = super.performDefaultImplementation() else { return NSNumber(booleanLiteral:false) }
|
||||
guard let result = super.performDefaultImplementation() else { return NSNumber(booleanLiteral: false) }
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,17 +13,17 @@ import Articles
|
||||
@objc(ScriptableArticle)
|
||||
class ScriptableArticle: NSObject, UniqueIdScriptingObject, ScriptingObjectContainer {
|
||||
|
||||
let article:Article
|
||||
let container:ScriptingObjectContainer
|
||||
|
||||
init (_ article:Article, container:ScriptingObjectContainer) {
|
||||
let article: Article
|
||||
let container: ScriptingObjectContainer
|
||||
|
||||
init (_ article: Article, container: ScriptingObjectContainer) {
|
||||
self.article = article
|
||||
self.container = container
|
||||
}
|
||||
|
||||
@objc(objectSpecifier)
|
||||
override var objectSpecifier: NSScriptObjectSpecifier? {
|
||||
let scriptObjectSpecifier = self.container.makeFormUniqueIDScriptObjectSpecifier(forObject:self)
|
||||
let scriptObjectSpecifier = self.container.makeFormUniqueIDScriptObjectSpecifier(forObject: self)
|
||||
return (scriptObjectSpecifier)
|
||||
}
|
||||
|
||||
@@ -39,76 +39,76 @@ class ScriptableArticle: NSObject, UniqueIdScriptingObject, ScriptingObjectConta
|
||||
// article.uniqueID here is the feed unique id
|
||||
|
||||
@objc(uniqueId)
|
||||
var scriptingUniqueId:Any {
|
||||
var scriptingUniqueId: Any {
|
||||
return article.uniqueID
|
||||
}
|
||||
|
||||
// MARK: --- ScriptingObjectContainer protocol ---
|
||||
|
||||
|
||||
var scriptingClassDescription: NSScriptClassDescription {
|
||||
return self.classDescription as! NSScriptClassDescription
|
||||
}
|
||||
|
||||
func deleteElement(_ element:ScriptingObject) {
|
||||
print ("delete event not handled")
|
||||
|
||||
func deleteElement(_ element: ScriptingObject) {
|
||||
print("delete event not handled")
|
||||
}
|
||||
|
||||
// MARK: --- Scriptable properties ---
|
||||
|
||||
|
||||
@objc(url)
|
||||
var url:String? {
|
||||
var url: String? {
|
||||
return article.preferredLink
|
||||
}
|
||||
|
||||
@objc(permalink)
|
||||
var permalink:String? {
|
||||
var permalink: String? {
|
||||
return article.link
|
||||
}
|
||||
|
||||
@objc(externalUrl)
|
||||
var externalUrl:String? {
|
||||
var externalUrl: String? {
|
||||
return article.externalLink
|
||||
}
|
||||
|
||||
|
||||
@objc(title)
|
||||
var title:String {
|
||||
var title: String {
|
||||
return article.title ?? ""
|
||||
}
|
||||
|
||||
@objc(contents)
|
||||
var contents:String {
|
||||
var contents: String {
|
||||
return article.contentText ?? ""
|
||||
}
|
||||
|
||||
@objc(html)
|
||||
var html:String {
|
||||
var html: String {
|
||||
return article.contentHTML ?? ""
|
||||
}
|
||||
|
||||
@objc(summary)
|
||||
var summary:String {
|
||||
var summary: String {
|
||||
return article.summary ?? ""
|
||||
}
|
||||
|
||||
@objc(datePublished)
|
||||
var datePublished:Date? {
|
||||
var datePublished: Date? {
|
||||
return article.datePublished
|
||||
}
|
||||
|
||||
@objc(dateModified)
|
||||
var dateModified:Date? {
|
||||
var dateModified: Date? {
|
||||
return article.dateModified
|
||||
}
|
||||
|
||||
@objc(dateArrived)
|
||||
var dateArrived:Date {
|
||||
var dateArrived: Date {
|
||||
return article.status.dateArrived
|
||||
}
|
||||
|
||||
@objc(read)
|
||||
var read:Bool {
|
||||
var read: Bool {
|
||||
get {
|
||||
return article.status.boolStatus(forKey:.read)
|
||||
return article.status.boolStatus(forKey: .read)
|
||||
}
|
||||
set {
|
||||
markArticles([self.article], statusKey: .read, flag: newValue)
|
||||
@@ -116,9 +116,9 @@ class ScriptableArticle: NSObject, UniqueIdScriptingObject, ScriptingObjectConta
|
||||
}
|
||||
|
||||
@objc(starred)
|
||||
var starred:Bool {
|
||||
var starred: Bool {
|
||||
get {
|
||||
return article.status.boolStatus(forKey:.starred)
|
||||
return article.status.boolStatus(forKey: .starred)
|
||||
}
|
||||
set {
|
||||
markArticles([self.article], statusKey: .starred, flag: newValue)
|
||||
@@ -126,19 +126,19 @@ class ScriptableArticle: NSObject, UniqueIdScriptingObject, ScriptingObjectConta
|
||||
}
|
||||
|
||||
@objc(deleted)
|
||||
var deleted:Bool {
|
||||
var deleted: Bool {
|
||||
return false
|
||||
}
|
||||
|
||||
@objc(imageURL)
|
||||
var imageURL:String {
|
||||
var imageURL: String {
|
||||
return article.imageLink ?? ""
|
||||
}
|
||||
|
||||
|
||||
@objc(authors)
|
||||
var authors:NSArray {
|
||||
var authors: NSArray {
|
||||
let articleAuthors = article.authors ?? []
|
||||
return articleAuthors.map { ScriptableAuthor($0, container:self) } as NSArray
|
||||
return articleAuthors.map { ScriptableAuthor($0, container: self) } as NSArray
|
||||
}
|
||||
|
||||
@objc(feed)
|
||||
|
||||
@@ -13,17 +13,17 @@ import Articles
|
||||
@objc(ScriptableAuthor)
|
||||
class ScriptableAuthor: NSObject, UniqueIdScriptingObject {
|
||||
|
||||
let author:Author
|
||||
let container:ScriptingObjectContainer
|
||||
|
||||
init (_ author:Author, container:ScriptingObjectContainer) {
|
||||
let author: Author
|
||||
let container: ScriptingObjectContainer
|
||||
|
||||
init (_ author: Author, container: ScriptingObjectContainer) {
|
||||
self.author = author
|
||||
self.container = container
|
||||
}
|
||||
|
||||
@objc(objectSpecifier)
|
||||
override var objectSpecifier: NSScriptObjectSpecifier? {
|
||||
let scriptObjectSpecifier = self.container.makeFormUniqueIDScriptObjectSpecifier(forObject:self)
|
||||
let scriptObjectSpecifier = self.container.makeFormUniqueIDScriptObjectSpecifier(forObject: self)
|
||||
return (scriptObjectSpecifier)
|
||||
}
|
||||
|
||||
@@ -41,29 +41,29 @@ class ScriptableAuthor: NSObject, UniqueIdScriptingObject {
|
||||
// MARK: --- UniqueIdScriptingObject protocol ---
|
||||
|
||||
@objc(uniqueId)
|
||||
var scriptingUniqueId:Any {
|
||||
var scriptingUniqueId: Any {
|
||||
return author.authorID
|
||||
}
|
||||
|
||||
|
||||
// MARK: --- Scriptable properties ---
|
||||
|
||||
|
||||
@objc(url)
|
||||
var url:String {
|
||||
var url: String {
|
||||
return self.author.url ?? ""
|
||||
}
|
||||
|
||||
|
||||
@objc(name)
|
||||
var name:String {
|
||||
var name: String {
|
||||
return self.author.name ?? ""
|
||||
}
|
||||
|
||||
@objc(avatarURL)
|
||||
var avatarURL:String {
|
||||
var avatarURL: String {
|
||||
return self.author.avatarURL ?? ""
|
||||
}
|
||||
|
||||
@objc(emailAddress)
|
||||
var emailAddress:String {
|
||||
var emailAddress: String {
|
||||
return self.author.emailAddress ?? ""
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,17 +14,17 @@ import RSCore
|
||||
@objc(ScriptableFolder)
|
||||
class ScriptableFolder: NSObject, UniqueIdScriptingObject, ScriptingObjectContainer {
|
||||
|
||||
let folder:Folder
|
||||
let container:ScriptingObjectContainer
|
||||
let folder: Folder
|
||||
let container: ScriptingObjectContainer
|
||||
|
||||
init (_ folder:Folder, container:ScriptingObjectContainer) {
|
||||
init (_ folder: Folder, container: ScriptingObjectContainer) {
|
||||
self.folder = folder
|
||||
self.container = container
|
||||
}
|
||||
|
||||
@objc(objectSpecifier)
|
||||
override var objectSpecifier: NSScriptObjectSpecifier? {
|
||||
let scriptObjectSpecifier = self.container.makeFormUniqueIDScriptObjectSpecifier(forObject:self)
|
||||
let scriptObjectSpecifier = self.container.makeFormUniqueIDScriptObjectSpecifier(forObject: self)
|
||||
return (scriptObjectSpecifier)
|
||||
}
|
||||
|
||||
@@ -40,20 +40,20 @@ class ScriptableFolder: NSObject, UniqueIdScriptingObject, ScriptingObjectContai
|
||||
// but in either case it seems like the accountID would be used as the keydata, so I chose ID
|
||||
|
||||
@objc(uniqueId)
|
||||
var scriptingUniqueId:Any {
|
||||
var scriptingUniqueId: Any {
|
||||
return folder.folderID
|
||||
}
|
||||
|
||||
|
||||
// MARK: --- ScriptingObjectContainer protocol ---
|
||||
|
||||
|
||||
var scriptingClassDescription: NSScriptClassDescription {
|
||||
return self.classDescription as! NSScriptClassDescription
|
||||
}
|
||||
|
||||
func deleteElement(_ element:ScriptingObject) {
|
||||
|
||||
func deleteElement(_ element: ScriptingObject) {
|
||||
if let scriptableFeed = element as? ScriptableFeed {
|
||||
BatchUpdate.shared.perform {
|
||||
folder.account?.removeFeed(scriptableFeed.feed, from: folder) { result in }
|
||||
folder.account?.removeFeed(scriptableFeed.feed, from: folder) { _ in }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -65,52 +65,52 @@ class ScriptableFolder: NSObject, UniqueIdScriptingObject, ScriptingObjectContai
|
||||
or
|
||||
tell account X to make new folder at end with properties {name:"new folder name"}
|
||||
*/
|
||||
class func handleCreateElement(command:NSCreateCommand) -> Any? {
|
||||
guard command.isCreateCommand(forClass:"fold") else { return nil }
|
||||
let name = command.property(forKey:"name") as? String ?? ""
|
||||
class func handleCreateElement(command: NSCreateCommand) -> Any? {
|
||||
guard command.isCreateCommand(forClass: "fold") else { return nil }
|
||||
let name = command.property(forKey: "name") as? String ?? ""
|
||||
|
||||
// some combination of the tell target and the location specifier ("in" or "at")
|
||||
// identifies where the new folder should be created
|
||||
let (account, folder) = command.accountAndFolderForNewChild()
|
||||
guard folder == nil else {
|
||||
print("support for folders within folders is NYI");
|
||||
print("support for folders within folders is NYI")
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
command.suspendExecution()
|
||||
|
||||
|
||||
account.addFolder(name) { result in
|
||||
switch result {
|
||||
case .success(let folder):
|
||||
let scriptableAccount = ScriptableAccount(account)
|
||||
let scriptableFolder = ScriptableFolder(folder, container:scriptableAccount)
|
||||
command.resumeExecution(withResult:scriptableFolder.objectSpecifier)
|
||||
let scriptableFolder = ScriptableFolder(folder, container: scriptableAccount)
|
||||
command.resumeExecution(withResult: scriptableFolder.objectSpecifier)
|
||||
case .failure:
|
||||
command.resumeExecution(withResult:nil)
|
||||
command.resumeExecution(withResult: nil)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
// MARK: --- Scriptable elements ---
|
||||
|
||||
|
||||
@objc(feeds)
|
||||
var feeds:NSArray {
|
||||
var feeds: NSArray {
|
||||
let feeds = Array(folder.topLevelFeeds)
|
||||
return feeds.map { ScriptableFeed($0, container:self) } as NSArray
|
||||
return feeds.map { ScriptableFeed($0, container: self) } as NSArray
|
||||
}
|
||||
|
||||
// MARK: --- Scriptable properties ---
|
||||
|
||||
|
||||
@objc(name)
|
||||
var name:String {
|
||||
var name: String {
|
||||
return self.folder.name ?? ""
|
||||
}
|
||||
|
||||
@objc(opmlRepresentation)
|
||||
var opmlRepresentation:String {
|
||||
return self.folder.OPMLString(indentLevel:0)
|
||||
var opmlRepresentation: String {
|
||||
return self.folder.OPMLString(indentLevel: 0)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -13,4 +13,3 @@ protocol ScriptingMainWindowController {
|
||||
var scriptingCurrentArticle: Article? { get }
|
||||
var scriptingSelectedArticles: [Article] { get }
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import AppKit
|
||||
import Account
|
||||
import Articles
|
||||
|
||||
extension NSApplication : ScriptingObjectContainer {
|
||||
extension NSApplication: ScriptingObjectContainer {
|
||||
|
||||
// MARK: --- ScriptingObjectContainer protocol ---
|
||||
|
||||
@@ -18,21 +18,21 @@ extension NSApplication : ScriptingObjectContainer {
|
||||
return NSApplication.shared.classDescription as! NSScriptClassDescription
|
||||
}
|
||||
|
||||
func deleteElement(_ element:ScriptingObject) {
|
||||
print ("delete event not handled")
|
||||
func deleteElement(_ element: ScriptingObject) {
|
||||
print("delete event not handled")
|
||||
}
|
||||
|
||||
var scriptingKey: String {
|
||||
return "application"
|
||||
}
|
||||
|
||||
|
||||
@objc(currentArticle)
|
||||
func currentArticle() -> ScriptableArticle? {
|
||||
var scriptableArticle: ScriptableArticle?
|
||||
if let currentArticle = appDelegate.scriptingCurrentArticle {
|
||||
if let feed = currentArticle.feed {
|
||||
let scriptableFeed = ScriptableFeed(feed, container:self)
|
||||
scriptableArticle = ScriptableArticle(currentArticle, container:scriptableFeed)
|
||||
let scriptableFeed = ScriptableFeed(feed, container: self)
|
||||
scriptableArticle = ScriptableArticle(currentArticle, container: scriptableFeed)
|
||||
}
|
||||
}
|
||||
return scriptableArticle
|
||||
@@ -41,8 +41,8 @@ extension NSApplication : ScriptingObjectContainer {
|
||||
@objc(selectedArticles)
|
||||
func selectedArticles() -> NSArray {
|
||||
let articles = appDelegate.scriptingSelectedArticles
|
||||
let scriptableArticles:[ScriptableArticle] = articles.compactMap { article in
|
||||
if let feed = article.feed, let account = feed.account {
|
||||
let scriptableArticles: [ScriptableArticle] = articles.compactMap { article in
|
||||
if let feed = article.feed, let account = feed.account {
|
||||
let scriptableFeed = ScriptableFeed(feed, container: ScriptableAccount(account))
|
||||
return ScriptableArticle(article, container: scriptableFeed)
|
||||
} else {
|
||||
@@ -59,11 +59,11 @@ extension NSApplication : ScriptingObjectContainer {
|
||||
let accounts = AccountManager.shared.accounts
|
||||
return accounts.map { ScriptableAccount($0) } as NSArray
|
||||
}
|
||||
|
||||
|
||||
@objc(valueInAccountsWithUniqueID:)
|
||||
func valueInAccounts(withUniqueID id:String) -> ScriptableAccount? {
|
||||
func valueInAccounts(withUniqueID id: String) -> ScriptableAccount? {
|
||||
let accounts = AccountManager.shared.accounts
|
||||
guard let account = accounts.first(where:{$0.accountID == id}) else { return nil }
|
||||
guard let account = accounts.first(where: {$0.accountID == id}) else { return nil }
|
||||
return ScriptableAccount(account)
|
||||
}
|
||||
|
||||
@@ -72,10 +72,10 @@ extension NSApplication : ScriptingObjectContainer {
|
||||
this allows a script like 'articles of feed "The Shape of Everything"' as a shorthand
|
||||
for 'articles of feed "The Shape of Everything" of account "On My Mac"'
|
||||
*/
|
||||
|
||||
|
||||
func allFeeds() -> [Feed] {
|
||||
let accounts = AccountManager.shared.activeAccounts
|
||||
let emptyFeeds:[Feed] = []
|
||||
let emptyFeeds: [Feed] = []
|
||||
return accounts.reduce(emptyFeeds) { (result, nthAccount) -> [Feed] in
|
||||
let accountFeeds = Array(nthAccount.topLevelFeeds)
|
||||
return result + accountFeeds
|
||||
@@ -85,15 +85,13 @@ extension NSApplication : ScriptingObjectContainer {
|
||||
@objc(feeds)
|
||||
func feeds() -> NSArray {
|
||||
let feeds = self.allFeeds()
|
||||
return feeds.map { ScriptableFeed($0, container:self) } as NSArray
|
||||
return feeds.map { ScriptableFeed($0, container: self) } as NSArray
|
||||
}
|
||||
|
||||
@objc(valueInFeedsWithUniqueID:)
|
||||
func valueInFeeds(withUniqueID id:String) -> ScriptableFeed? {
|
||||
func valueInFeeds(withUniqueID id: String) -> ScriptableFeed? {
|
||||
let feeds = self.allFeeds()
|
||||
guard let feed = feeds.first(where:{$0.feedID == id}) else { return nil }
|
||||
return ScriptableFeed(feed, container:self)
|
||||
guard let feed = feeds.first(where: {$0.feedID == id}) else { return nil }
|
||||
return ScriptableFeed(feed, container: self)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -10,43 +10,43 @@ import Foundation
|
||||
import Account
|
||||
|
||||
extension NSScriptCommand {
|
||||
func property(forKey key:String) -> Any? {
|
||||
if let evaluatedArguments = self.evaluatedArguments {
|
||||
func property(forKey key: String) -> Any? {
|
||||
if let evaluatedArguments = self.evaluatedArguments {
|
||||
if let props = evaluatedArguments["KeyDictionary"] as? [String: Any] {
|
||||
return props[key]
|
||||
return props[key]
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func isCreateCommand(forClass whatClass:String) -> Bool {
|
||||
|
||||
func isCreateCommand(forClass whatClass: String) -> Bool {
|
||||
guard let arguments = self.arguments else {return false}
|
||||
guard let newObjectClass = arguments["ObjectClass"] as? Int else {return false}
|
||||
guard (newObjectClass.fourCharCode == whatClass.fourCharCode) else {return false}
|
||||
guard newObjectClass.fourCharCode == whatClass.fourCharCode else {return false}
|
||||
return true
|
||||
}
|
||||
|
||||
func accountAndFolderForNewChild() -> (Account, Folder?) {
|
||||
let appleEvent = self.appleEvent
|
||||
var account = AccountManager.shared.defaultAccount
|
||||
var folder:Folder? = nil
|
||||
var folder: Folder?
|
||||
if let appleEvent = appleEvent {
|
||||
var descriptorToConsider:NSAppleEventDescriptor?
|
||||
if let insertionLocationDescriptor = appleEvent.paramDescriptor(forKeyword:keyAEInsertHere) {
|
||||
var descriptorToConsider: NSAppleEventDescriptor?
|
||||
if let insertionLocationDescriptor = appleEvent.paramDescriptor(forKeyword: keyAEInsertHere) {
|
||||
print("insertionLocation : \(insertionLocationDescriptor)")
|
||||
// insertion location can be a typeObjectSpecifier, e.g. 'in account "Acct"'
|
||||
// or a typeInsertionLocation, e.g. 'at end of folder "
|
||||
if (insertionLocationDescriptor.descriptorType == "insl".fourCharCode) {
|
||||
if insertionLocationDescriptor.descriptorType == "insl".fourCharCode {
|
||||
descriptorToConsider = insertionLocationDescriptor.forKeyword("kobj".fourCharCode)
|
||||
} else if ( insertionLocationDescriptor.descriptorType == "obj ".fourCharCode) {
|
||||
} else if insertionLocationDescriptor.descriptorType == "obj ".fourCharCode {
|
||||
descriptorToConsider = insertionLocationDescriptor
|
||||
}
|
||||
} else if let subjectDescriptor = appleEvent.attributeDescriptor(forKeyword:"subj".fourCharCode) {
|
||||
} else if let subjectDescriptor = appleEvent.attributeDescriptor(forKeyword: "subj".fourCharCode) {
|
||||
descriptorToConsider = subjectDescriptor
|
||||
}
|
||||
|
||||
|
||||
if let descriptorToConsider = descriptorToConsider {
|
||||
guard let newContainerSpecifier = NSScriptObjectSpecifier(descriptor:descriptorToConsider) else {return (account, folder)}
|
||||
guard let newContainerSpecifier = NSScriptObjectSpecifier(descriptor: descriptorToConsider) else {return (account, folder)}
|
||||
let newContainer = newContainerSpecifier.objectsByEvaluatingSpecifier
|
||||
if let scriptableAccount = newContainer as? ScriptableAccount {
|
||||
account = scriptableAccount.account
|
||||
|
||||
@@ -9,14 +9,14 @@
|
||||
import Foundation
|
||||
|
||||
protocol ScriptingObject {
|
||||
var objectSpecifier: NSScriptObjectSpecifier? { get }
|
||||
var objectSpecifier: NSScriptObjectSpecifier? { get }
|
||||
var scriptingKey: String { get }
|
||||
}
|
||||
|
||||
protocol NamedScriptingObject: ScriptingObject {
|
||||
var name:String { get }
|
||||
var name: String { get }
|
||||
}
|
||||
|
||||
protocol UniqueIdScriptingObject: ScriptingObject {
|
||||
var scriptingUniqueId:Any { get }
|
||||
var scriptingUniqueId: Any { get }
|
||||
}
|
||||
|
||||
@@ -10,30 +10,29 @@ import AppKit
|
||||
import Account
|
||||
|
||||
protocol ScriptingObjectContainer: ScriptingObject {
|
||||
var scriptingClassDescription:NSScriptClassDescription { get }
|
||||
func deleteElement(_ element:ScriptingObject)
|
||||
var scriptingClassDescription: NSScriptClassDescription { get }
|
||||
func deleteElement(_ element: ScriptingObject)
|
||||
}
|
||||
|
||||
extension ScriptingObjectContainer {
|
||||
|
||||
func makeFormNameScriptObjectSpecifier(forObject object:NamedScriptingObject) -> NSScriptObjectSpecifier? {
|
||||
func makeFormNameScriptObjectSpecifier(forObject object: NamedScriptingObject) -> NSScriptObjectSpecifier? {
|
||||
let containerClassDescription = self.scriptingClassDescription
|
||||
let containerScriptObjectSpecifier = self.objectSpecifier
|
||||
let scriptingKey = object.scriptingKey
|
||||
let name = object.name
|
||||
let specifier = NSNameSpecifier(containerClassDescription:containerClassDescription,
|
||||
containerSpecifier:containerScriptObjectSpecifier, key:scriptingKey, name:name)
|
||||
let specifier = NSNameSpecifier(containerClassDescription: containerClassDescription,
|
||||
containerSpecifier: containerScriptObjectSpecifier, key: scriptingKey, name: name)
|
||||
return specifier
|
||||
}
|
||||
|
||||
func makeFormUniqueIDScriptObjectSpecifier(forObject object:UniqueIdScriptingObject) -> NSScriptObjectSpecifier? {
|
||||
|
||||
func makeFormUniqueIDScriptObjectSpecifier(forObject object: UniqueIdScriptingObject) -> NSScriptObjectSpecifier? {
|
||||
let containerClassDescription = self.scriptingClassDescription
|
||||
let containerScriptObjectSpecifier = self.objectSpecifier
|
||||
let scriptingKey = object.scriptingKey
|
||||
let uniqueId = object.scriptingUniqueId
|
||||
let specifier = NSUniqueIDSpecifier(containerClassDescription:containerClassDescription,
|
||||
containerSpecifier:containerScriptObjectSpecifier, key:scriptingKey, uniqueID: uniqueId)
|
||||
let specifier = NSUniqueIDSpecifier(containerClassDescription: containerClassDescription,
|
||||
containerSpecifier: containerScriptObjectSpecifier, key: scriptingKey, uniqueID: uniqueId)
|
||||
return specifier
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,15 +16,15 @@ class ScriptableFeed: NSObject, UniqueIdScriptingObject, ScriptingObjectContaine
|
||||
|
||||
let feed: Feed
|
||||
let container: ScriptingObjectContainer
|
||||
|
||||
init (_ feed:Feed, container:ScriptingObjectContainer) {
|
||||
|
||||
init (_ feed: Feed, container: ScriptingObjectContainer) {
|
||||
self.feed = feed
|
||||
self.container = container
|
||||
}
|
||||
|
||||
@objc(objectSpecifier)
|
||||
override var objectSpecifier: NSScriptObjectSpecifier? {
|
||||
let scriptObjectSpecifier = self.container.makeFormUniqueIDScriptObjectSpecifier(forObject:self)
|
||||
let scriptObjectSpecifier = self.container.makeFormUniqueIDScriptObjectSpecifier(forObject: self)
|
||||
return (scriptObjectSpecifier)
|
||||
}
|
||||
|
||||
@@ -44,56 +44,56 @@ class ScriptableFeed: NSObject, UniqueIdScriptingObject, ScriptingObjectContaine
|
||||
// I am not sure if account should prefer to be specified by name or by ID
|
||||
// but in either case it seems like the accountID would be used as the keydata, so I chose ID
|
||||
@objc(uniqueId)
|
||||
var scriptingUniqueId:Any {
|
||||
var scriptingUniqueId: Any {
|
||||
return feed.feedID
|
||||
}
|
||||
|
||||
// MARK: --- ScriptingObjectContainer protocol ---
|
||||
|
||||
|
||||
var scriptingClassDescription: NSScriptClassDescription {
|
||||
return self.classDescription as! NSScriptClassDescription
|
||||
}
|
||||
|
||||
func deleteElement(_ element:ScriptingObject) {
|
||||
|
||||
func deleteElement(_ element: ScriptingObject) {
|
||||
}
|
||||
|
||||
// MARK: --- handle NSCreateCommand ---
|
||||
|
||||
class func urlForNewFeed(arguments:[String:Any]) -> String? {
|
||||
var url:String?
|
||||
class func urlForNewFeed(arguments: [String: Any]) -> String? {
|
||||
var url: String?
|
||||
if let withDataParam = arguments["ObjectData"] {
|
||||
if let objectDataDescriptor = withDataParam as? NSAppleEventDescriptor {
|
||||
url = objectDataDescriptor.stringValue
|
||||
}
|
||||
} else if let withPropsParam = arguments["ObjectProperties"] as? [String:Any] {
|
||||
} else if let withPropsParam = arguments["ObjectProperties"] as? [String: Any] {
|
||||
url = withPropsParam["url"] as? String
|
||||
}
|
||||
return url
|
||||
}
|
||||
|
||||
class func scriptableFeed(_ feed:Feed, account:Account, folder:Folder?) -> ScriptableFeed {
|
||||
|
||||
class func scriptableFeed(_ feed: Feed, account: Account, folder: Folder?) -> ScriptableFeed {
|
||||
let scriptableAccount = ScriptableAccount(account)
|
||||
if let folder = folder {
|
||||
let scriptableFolder = ScriptableFolder(folder, container:scriptableAccount)
|
||||
return ScriptableFeed(feed, container:scriptableFolder)
|
||||
} else {
|
||||
return ScriptableFeed(feed, container:scriptableAccount)
|
||||
let scriptableFolder = ScriptableFolder(folder, container: scriptableAccount)
|
||||
return ScriptableFeed(feed, container: scriptableFolder)
|
||||
} else {
|
||||
return ScriptableFeed(feed, container: scriptableAccount)
|
||||
}
|
||||
}
|
||||
|
||||
class func handleCreateElement(command:NSCreateCommand) -> Any? {
|
||||
guard command.isCreateCommand(forClass:"Feed") else { return nil }
|
||||
|
||||
class func handleCreateElement(command: NSCreateCommand) -> Any? {
|
||||
guard command.isCreateCommand(forClass: "Feed") else { return nil }
|
||||
guard let arguments = command.arguments else {return nil}
|
||||
let titleFromArgs = command.property(forKey:"name") as? String
|
||||
let titleFromArgs = command.property(forKey: "name") as? String
|
||||
let (account, folder) = command.accountAndFolderForNewChild()
|
||||
guard let url = self.urlForNewFeed(arguments:arguments) else {return nil}
|
||||
|
||||
if let existingFeed = account.existingFeed(withURL:url) {
|
||||
return scriptableFeed(existingFeed, account:account, folder:folder).objectSpecifier
|
||||
guard let url = self.urlForNewFeed(arguments: arguments) else {return nil}
|
||||
|
||||
if let existingFeed = account.existingFeed(withURL: url) {
|
||||
return scriptableFeed(existingFeed, account: account, folder: folder).objectSpecifier
|
||||
}
|
||||
|
||||
|
||||
let container: Container = folder != nil ? folder! : account
|
||||
|
||||
|
||||
// We need to download the feed and parse it.
|
||||
// Parser does the callback for the download on the main thread.
|
||||
// Because we can't wait here (on the main thread) for the callback, we have to return from this function.
|
||||
@@ -101,83 +101,83 @@ class ScriptableFeed: NSObject, UniqueIdScriptingObject, ScriptingObjectContaine
|
||||
// but we don’t yet have the result of the event yet, so we prevent the Apple event from returning by calling
|
||||
// suspendExecution(). When we get the callback, we supply the event result and call resumeExecution().
|
||||
command.suspendExecution()
|
||||
|
||||
|
||||
account.createFeed(url: url, name: titleFromArgs, container: container, validateFeed: true) { result in
|
||||
switch result {
|
||||
case .success(let feed):
|
||||
NotificationCenter.default.post(name: .UserDidAddFeed, object: self, userInfo: [UserInfoKey.feed: feed])
|
||||
let scriptableFeed = self.scriptableFeed(feed, account:account, folder:folder)
|
||||
command.resumeExecution(withResult:scriptableFeed.objectSpecifier)
|
||||
let scriptableFeed = self.scriptableFeed(feed, account: account, folder: folder)
|
||||
command.resumeExecution(withResult: scriptableFeed.objectSpecifier)
|
||||
case .failure:
|
||||
command.resumeExecution(withResult:nil)
|
||||
command.resumeExecution(withResult: nil)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// MARK: --- Scriptable properties ---
|
||||
|
||||
@objc(url)
|
||||
var url:String {
|
||||
var url: String {
|
||||
return self.feed.url
|
||||
}
|
||||
|
||||
|
||||
@objc(name)
|
||||
var name:String {
|
||||
var name: String {
|
||||
return self.feed.name ?? ""
|
||||
}
|
||||
|
||||
@objc(homePageURL)
|
||||
var homePageURL:String {
|
||||
var homePageURL: String {
|
||||
return self.feed.homePageURL ?? ""
|
||||
}
|
||||
|
||||
@objc(iconURL)
|
||||
var iconURL:String {
|
||||
var iconURL: String {
|
||||
return self.feed.iconURL ?? ""
|
||||
}
|
||||
|
||||
@objc(faviconURL)
|
||||
var faviconURL:String {
|
||||
var faviconURL: String {
|
||||
return self.feed.faviconURL ?? ""
|
||||
}
|
||||
|
||||
@objc(opmlRepresentation)
|
||||
var opmlRepresentation:String {
|
||||
return self.feed.OPMLString(indentLevel:0)
|
||||
var opmlRepresentation: String {
|
||||
return self.feed.OPMLString(indentLevel: 0)
|
||||
}
|
||||
|
||||
|
||||
// MARK: --- scriptable elements ---
|
||||
|
||||
@objc(authors)
|
||||
var authors:NSArray {
|
||||
var authors: NSArray {
|
||||
let feedAuthors = feed.authors ?? []
|
||||
return feedAuthors.map { ScriptableAuthor($0, container:self) } as NSArray
|
||||
return feedAuthors.map { ScriptableAuthor($0, container: self) } as NSArray
|
||||
}
|
||||
|
||||
|
||||
@objc(valueInAuthorsWithUniqueID:)
|
||||
func valueInAuthors(withUniqueID id:String) -> ScriptableAuthor? {
|
||||
guard let author = feed.authors?.first(where:{$0.authorID == id}) else { return nil }
|
||||
return ScriptableAuthor(author, container:self)
|
||||
func valueInAuthors(withUniqueID id: String) -> ScriptableAuthor? {
|
||||
guard let author = feed.authors?.first(where: {$0.authorID == id}) else { return nil }
|
||||
return ScriptableAuthor(author, container: self)
|
||||
}
|
||||
|
||||
|
||||
@objc(articles)
|
||||
var articles:NSArray {
|
||||
var articles: NSArray {
|
||||
let feedArticles = (try? feed.fetchArticles()) ?? Set<Article>()
|
||||
// the articles are a set, use the sorting algorithm from the viewer
|
||||
let sortedArticles = feedArticles.sorted(by:{
|
||||
let sortedArticles = feedArticles.sorted(by: {
|
||||
return $0.logicalDatePublished > $1.logicalDatePublished
|
||||
})
|
||||
return sortedArticles.map { ScriptableArticle($0, container:self) } as NSArray
|
||||
return sortedArticles.map { ScriptableArticle($0, container: self) } as NSArray
|
||||
}
|
||||
|
||||
|
||||
@objc(valueInArticlesWithUniqueID:)
|
||||
func valueInArticles(withUniqueID id:String) -> ScriptableArticle? {
|
||||
func valueInArticles(withUniqueID id: String) -> ScriptableArticle? {
|
||||
let articles = (try? feed.fetchArticles()) ?? Set<Article>()
|
||||
guard let article = articles.first(where:{$0.uniqueID == id}) else { return nil }
|
||||
return ScriptableArticle(article, container:self)
|
||||
guard let article = articles.first(where: {$0.uniqueID == id}) else { return nil }
|
||||
return ScriptableArticle(article, container: self)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user