mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2025-02-03 20:37:34 +01:00
Fix places in iOS app that need to be using the undo manager
This commit is contained in:
parent
a2a4616a48
commit
b3a5929d6d
@ -711,10 +711,7 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func markAllAsRead(_ articles: [Article]) {
|
func markAllAsRead(_ articles: [Article]) {
|
||||||
guard let undoManager = undoManager, let markReadCommand = MarkStatusCommand(initialArticles: articles, markingRead: true, undoManager: undoManager) else {
|
markArticlesWithUndo(articles, statusKey: .read, flag: true)
|
||||||
return
|
|
||||||
}
|
|
||||||
runCommand(markReadCommand)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func markAllAsRead() {
|
func markAllAsRead() {
|
||||||
@ -747,42 +744,34 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider {
|
|||||||
|
|
||||||
func markAsReadForCurrentArticle() {
|
func markAsReadForCurrentArticle() {
|
||||||
if let article = currentArticle {
|
if let article = currentArticle {
|
||||||
markArticles(Set([article]), statusKey: .read, flag: true)
|
markArticlesWithUndo([article], statusKey: .read, flag: true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func markAsUnreadForCurrentArticle() {
|
func markAsUnreadForCurrentArticle() {
|
||||||
if let article = currentArticle {
|
if let article = currentArticle {
|
||||||
markArticles(Set([article]), statusKey: .read, flag: false)
|
markArticlesWithUndo([article], statusKey: .read, flag: false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func toggleReadForCurrentArticle() {
|
func toggleReadForCurrentArticle() {
|
||||||
if let article = currentArticle {
|
if let article = currentArticle {
|
||||||
markArticles(Set([article]), statusKey: .read, flag: !article.status.read)
|
toggleRead(article)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func toggleRead(_ article: Article) {
|
func toggleRead(_ article: Article) {
|
||||||
guard let undoManager = undoManager,
|
markArticlesWithUndo([article], statusKey: .read, flag: !article.status.read)
|
||||||
let markReadCommand = MarkStatusCommand(initialArticles: [article], markingRead: !article.status.read, undoManager: undoManager) else {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
runCommand(markReadCommand)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func toggleStarredForCurrentArticle() {
|
func toggleStarredForCurrentArticle() {
|
||||||
if let article = currentArticle {
|
if let article = currentArticle {
|
||||||
markArticles(Set([article]), statusKey: .starred, flag: !article.status.starred)
|
toggleStar(article)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func toggleStar(_ article: Article) {
|
func toggleStar(_ article: Article) {
|
||||||
guard let undoManager = undoManager,
|
markArticlesWithUndo([article], statusKey: .starred, flag: !article.status.starred)
|
||||||
let markReadCommand = MarkStatusCommand(initialArticles: [article], markingStarred: !article.status.starred, undoManager: undoManager) else {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
runCommand(markReadCommand)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func discloseFeed(_ feed: Feed, completion: (() -> Void)? = nil) {
|
func discloseFeed(_ feed: Feed, completion: (() -> Void)? = nil) {
|
||||||
@ -981,6 +970,13 @@ extension SceneCoordinator: ArticleExtractorDelegate {
|
|||||||
|
|
||||||
private extension SceneCoordinator {
|
private extension SceneCoordinator {
|
||||||
|
|
||||||
|
func markArticlesWithUndo(_ articles: [Article], statusKey: ArticleStatus.Key, flag: Bool) {
|
||||||
|
guard let undoManager = undoManager, let markReadCommand = MarkStatusCommand(initialArticles: articles, statusKey: statusKey, flag: flag, undoManager: undoManager) else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
runCommand(markReadCommand)
|
||||||
|
}
|
||||||
|
|
||||||
func updateUnreadCount() {
|
func updateUnreadCount() {
|
||||||
var count = 0
|
var count = 0
|
||||||
for article in articles {
|
for article in articles {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user