mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
Add mark all as read for feed functionality
This commit is contained in:
@@ -168,6 +168,10 @@ class MasterTimelineViewController: UITableViewController, UndoableCommandRunner
|
||||
alert.addAction(action)
|
||||
}
|
||||
|
||||
if let action = self.markAllInFeedAsReadAlertAction(indexPath: indexPath, completionHandler: completionHandler) {
|
||||
alert.addAction(action)
|
||||
}
|
||||
|
||||
let cancelTitle = NSLocalizedString("Cancel", comment: "Cancel")
|
||||
alert.addAction(UIAlertAction(title: cancelTitle, style: .cancel) { _ in
|
||||
completionHandler(true)
|
||||
@@ -202,6 +206,10 @@ class MasterTimelineViewController: UITableViewController, UndoableCommandRunner
|
||||
actions.append(action)
|
||||
}
|
||||
|
||||
if let action = self.markAllInFeedAsReadAction(indexPath: indexPath) {
|
||||
actions.append(action)
|
||||
}
|
||||
|
||||
return UIMenu(title: "", children: actions)
|
||||
|
||||
})
|
||||
@@ -562,4 +570,43 @@ private extension MasterTimelineViewController {
|
||||
return action
|
||||
}
|
||||
|
||||
func markAllInFeedAsReadAction(indexPath: IndexPath) -> UIAction? {
|
||||
guard let feed = coordinator.articles[indexPath.row].feed else {
|
||||
return nil
|
||||
}
|
||||
|
||||
let articles = Array(feed.fetchArticles())
|
||||
guard articles.canMarkAllAsRead() else {
|
||||
return nil
|
||||
}
|
||||
|
||||
let localizedMenuText = NSLocalizedString("Mark All as Read in “%@”", comment: "Command")
|
||||
let title = NSString.localizedStringWithFormat(localizedMenuText as NSString, feed.nameForDisplay) as String
|
||||
|
||||
let action = UIAction(title: title, image: AppAssets.markAllInFeedAsReadImage) { [weak self] action in
|
||||
self?.coordinator.markAllAsRead(articles)
|
||||
}
|
||||
return action
|
||||
}
|
||||
|
||||
func markAllInFeedAsReadAlertAction(indexPath: IndexPath, completionHandler: @escaping (Bool) -> Void) -> UIAlertAction? {
|
||||
guard let feed = coordinator.articles[indexPath.row].feed else {
|
||||
return nil
|
||||
}
|
||||
|
||||
let articles = Array(feed.fetchArticles())
|
||||
guard articles.canMarkAllAsRead() else {
|
||||
return nil
|
||||
}
|
||||
|
||||
let localizedMenuText = NSLocalizedString("Mark All as Read in “%@”", comment: "Command")
|
||||
let title = NSString.localizedStringWithFormat(localizedMenuText as NSString, feed.nameForDisplay) as String
|
||||
|
||||
let action = UIAlertAction(title: title, style: .default) { [weak self] action in
|
||||
self?.coordinator.markAllAsRead(articles)
|
||||
completionHandler(true)
|
||||
}
|
||||
return action
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user