diff --git a/AppleScript/Safari-OpenAllStarredArticles.applescript b/AppleScript/Safari-OpenAllStarredArticles.applescript new file mode 100644 index 000000000..cad33bb4d --- /dev/null +++ b/AppleScript/Safari-OpenAllStarredArticles.applescript @@ -0,0 +1,49 @@ +-- This script creates a new Safari window with all the starred articles in a NetNewsWire instance, each in its own tab + +-- declare the safariWindow property here so we can use is throughout the whole script + +property safariWindow : missing value + +-- the openTabInSafari() function opens a new tab in the appropriate window + +to openTabInSafari(theUrl) + tell application "Safari" + -- test if this is the first call to openTabInSafari() + if (my safariWindow is missing value) then + -- first time through, make a new window with the given url in the only tab + set newdoc to make new document at front with properties {URL:theUrl} + -- because we created the doucument "at front", we know it is window 1 + set safariWindow to window 1 + else + -- after the first time, make a new tab in the wndow we created the first tim + tell safariWindow + make new tab with properties {URL:theUrl} + end tell + end if + end tell +end openTabInSafari + + +-- the script starts here +-- First, initialize safariWindow to be missing value, so that the first time through +-- openTabInSafari() we'll make a new window to hold all our articles + +set safariWindow to missing value + + +-- Then we loop though all the feeds of all the accounts +-- for each feed, we find all the starred articles +--for each one of those, open a new tab in Safari + +tell application "NetNewsWire" + set allAccounts to every account + repeat with nthAccount in allAccounts + set allFeeds to every feed of nthAccount + repeat with nthFeed in allFeeds + set starredArticles to (get every article of nthFeed where starred is true) + repeat with nthArticle in starredArticles + my openTabInSafari(url of nthArticle) + end repeat + end repeat + end repeat +end tell diff --git a/Frameworks/Account/Account.swift b/Frameworks/Account/Account.swift index fb6a47caa..92875a79c 100644 --- a/Frameworks/Account/Account.swift +++ b/Frameworks/Account/Account.swift @@ -449,7 +449,7 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container, return feed } - public func removeFeed(_ feed: Feed, from container: Container?, completion: @escaping (Result) -> Void) { + public func removeFeed(_ feed: Feed, from container: Container, completion: @escaping (Result) -> Void) { delegate.removeFeed(for: self, with: feed, from: container, completion: completion) } diff --git a/Frameworks/Account/AccountDelegate.swift b/Frameworks/Account/AccountDelegate.swift index b4af6e7f0..5be29ebe6 100644 --- a/Frameworks/Account/AccountDelegate.swift +++ b/Frameworks/Account/AccountDelegate.swift @@ -37,7 +37,7 @@ protocol AccountDelegate { func createFeed(for account: Account, url: String, name: String?, container: Container, completion: @escaping (Result) -> Void) func renameFeed(for account: Account, with feed: Feed, to name: String, completion: @escaping (Result) -> Void) func addFeed(for account: Account, with: Feed, to container: Container, completion: @escaping (Result) -> Void) - func removeFeed(for account: Account, with feed: Feed, from container: Container?, completion: @escaping (Result) -> Void) + func removeFeed(for account: Account, with feed: Feed, from container: Container, completion: @escaping (Result) -> Void) func moveFeed(for account: Account, with feed: Feed, from: Container, to: Container, completion: @escaping (Result) -> Void) func restoreFeed(for account: Account, feed: Feed, container: Container, completion: @escaping (Result) -> Void) diff --git a/Frameworks/Account/Feedbin/FeedbinAccountDelegate.swift b/Frameworks/Account/Feedbin/FeedbinAccountDelegate.swift index beac0674e..9ff14275a 100644 --- a/Frameworks/Account/Feedbin/FeedbinAccountDelegate.swift +++ b/Frameworks/Account/Feedbin/FeedbinAccountDelegate.swift @@ -396,8 +396,7 @@ final class FeedbinAccountDelegate: AccountDelegate { } - func removeFeed(for account: Account, with feed: Feed, from container: Container?, completion: @escaping (Result) -> Void) { - retrieveCredentialsIfNecessary(account) + func removeFeed(for account: Account, with feed: Feed, from container: Container, completion: @escaping (Result) -> Void) { if feed.folderRelationship?.count ?? 0 > 1 { deleteTagging(for: account, with: feed, from: container, completion: completion) } else { diff --git a/Frameworks/Account/LocalAccount/LocalAccountDelegate.swift b/Frameworks/Account/LocalAccount/LocalAccountDelegate.swift index af5db8134..a9d2df907 100644 --- a/Frameworks/Account/LocalAccount/LocalAccountDelegate.swift +++ b/Frameworks/Account/LocalAccount/LocalAccountDelegate.swift @@ -140,8 +140,8 @@ final class LocalAccountDelegate: AccountDelegate { completion(.success(())) } - func removeFeed(for account: Account, with feed: Feed, from container: Container?, completion: @escaping (Result) -> Void) { - container?.removeFeed(feed) + func removeFeed(for account: Account, with feed: Feed, from container: Container, completion: @escaping (Result) -> Void) { + container.removeFeed(feed) completion(.success(())) } diff --git a/Frameworks/Account/ReaderAPI/ReaderAPIAccountDelegate.swift b/Frameworks/Account/ReaderAPI/ReaderAPIAccountDelegate.swift index 73d7cd499..4d1f7acf7 100644 --- a/Frameworks/Account/ReaderAPI/ReaderAPIAccountDelegate.swift +++ b/Frameworks/Account/ReaderAPI/ReaderAPIAccountDelegate.swift @@ -304,7 +304,7 @@ final class ReaderAPIAccountDelegate: AccountDelegate { } - func removeFeed(for account: Account, with feed: Feed, from container: Container?, completion: @escaping (Result) -> Void) { + func removeFeed(for account: Account, with feed: Feed, from container: Container, completion: @escaping (Result) -> Void) { if feed.folderRelationship?.count ?? 0 > 1 { deleteTagging(for: account, with: feed, from: container, completion: completion) } else { diff --git a/Mac/Scriptability/Account+Scriptability.swift b/Mac/Scriptability/Account+Scriptability.swift index 7b2fde624..eed7b5c6e 100644 --- a/Mac/Scriptability/Account+Scriptability.swift +++ b/Mac/Scriptability/Account+Scriptability.swift @@ -58,8 +58,10 @@ class ScriptableAccount: NSObject, UniqueIdScriptingObject, ScriptingObjectConta var container: Container? = nil 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!) { result in } } } diff --git a/Shared/Commands/DeleteCommand.swift b/Shared/Commands/DeleteCommand.swift index 8ea6584bd..6d1bda0e3 100644 --- a/Shared/Commands/DeleteCommand.swift +++ b/Shared/Commands/DeleteCommand.swift @@ -159,19 +159,28 @@ private struct SidebarItemSpecifier { func delete(completion: @escaping () -> Void) { if let feed = feed { + + guard let container = path.resolveContainer() else { + completion() + return + } + BatchUpdate.shared.start() - account?.removeFeed(feed, from: path.resolveContainer()) { result in + account?.removeFeed(feed, from: container) { result in BatchUpdate.shared.end() completion() self.checkResult(result) } + } else if let folder = folder { + BatchUpdate.shared.start() account?.removeFolder(folder) { result in BatchUpdate.shared.end() completion() self.checkResult(result) } + } }