implement 'current article' property of the application

Also, fix the unique-id based accessors (the four byte code  for id was
wrong in the sdef)
Add valueIn<Key>WithUniqueID accessors
Add a few protocols and protocol implementations for the AppDelegate
and MainWindowControllor so as to expose needed functionality for
scriptability
This commit is contained in:
Olof Hellman
2018-02-08 00:11:52 -08:00
parent 2e4217236b
commit 395af1420e
9 changed files with 192 additions and 10 deletions

View File

@@ -54,12 +54,29 @@ class ScriptableAccount: NSObject, UniqueIdScriptingObject, ScriptingObjectConta
return feeds.map { ScriptableFeed($0, container:self) } as NSArray
}
@objc(valueInFeedsWithUniqueID:)
func valueInFeeds(withUniqueID id:String) -> ScriptableFeed? {
let feeds = account.children.compactMap { $0 as? Feed }
guard let feed = feeds.first(where:{$0.feedID == id}) else { return nil }
return ScriptableFeed(feed, container:self)
}
@objc(folders)
var folders:NSArray {
let folders = account.children.compactMap { $0 as? Folder }
return folders.map { ScriptableFolder($0, container:self) } as NSArray
}
@objc(valueInFoldersWithUniqueID:)
func valueInFolders(withUniqueID id:NSNumber) -> ScriptableFolder? {
let folderId = id.intValue
let folders = account.children.compactMap { $0 as? Folder }
guard let folder = folders.first(where:{$0.folderID == folderId}) else { return nil }
return ScriptableFolder(folder, container:self)
}
// MARK: --- Scriptable properties ---
@objc(contents)