mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2025-01-31 11:14:54 +01:00
Create MarkAllReadCommand.swift.
This commit is contained in:
parent
d16f83c99a
commit
f388a9f4dc
46
Commands/MarkAllReadCommand.swift
Normal file
46
Commands/MarkAllReadCommand.swift
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
//
|
||||||
|
// MarkAllReadCommand.swift
|
||||||
|
// Evergreen
|
||||||
|
//
|
||||||
|
// Created by Brent Simmons on 10/26/17.
|
||||||
|
// Copyright © 2017 Ranchero Software. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
import RSCore
|
||||||
|
import Data
|
||||||
|
|
||||||
|
final class MarkAllReadCommand: UndoableCommand {
|
||||||
|
|
||||||
|
static private let actionName = NSLocalizedString("Mark All as Read", comment: "command")
|
||||||
|
let undoActionName = actionName
|
||||||
|
let redoActionName = actionName
|
||||||
|
let articles: Set<Article>
|
||||||
|
|
||||||
|
init(initialArticles: [Article]) {
|
||||||
|
|
||||||
|
// Filter out articles already read.
|
||||||
|
let unreadArticles = initialArticles.filter { !$0.status.read }
|
||||||
|
self.articles = Set(unreadArticles)
|
||||||
|
}
|
||||||
|
|
||||||
|
func perform() {
|
||||||
|
mark(read: true)
|
||||||
|
}
|
||||||
|
|
||||||
|
func undo() {
|
||||||
|
mark(read: false)
|
||||||
|
}
|
||||||
|
|
||||||
|
func redo() {
|
||||||
|
perform()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private extension MarkAllReadCommand {
|
||||||
|
|
||||||
|
func mark(read: Bool) {
|
||||||
|
|
||||||
|
markArticles(articles, statusKey: .read, flag: read)
|
||||||
|
}
|
||||||
|
}
|
@ -17,6 +17,7 @@
|
|||||||
846E773E1F6EF67A00A165E2 /* Account.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 846E773A1F6EF5D700A165E2 /* Account.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
846E773E1F6EF67A00A165E2 /* Account.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 846E773A1F6EF5D700A165E2 /* Account.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
||||||
846E77411F6EF6A100A165E2 /* Database.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 846E77211F6EF5D100A165E2 /* Database.framework */; };
|
846E77411F6EF6A100A165E2 /* Database.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 846E77211F6EF5D100A165E2 /* Database.framework */; };
|
||||||
846E77421F6EF6A100A165E2 /* Database.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 846E77211F6EF5D100A165E2 /* Database.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
846E77421F6EF6A100A165E2 /* Database.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 846E77211F6EF5D100A165E2 /* Database.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
||||||
|
84702AA41FA27AC0006B8943 /* MarkAllReadCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84702AA31FA27AC0006B8943 /* MarkAllReadCommand.swift */; };
|
||||||
849A97431ED9EAA9007D329B /* AddFolderWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 849A97421ED9EAA9007D329B /* AddFolderWindowController.swift */; };
|
849A97431ED9EAA9007D329B /* AddFolderWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 849A97421ED9EAA9007D329B /* AddFolderWindowController.swift */; };
|
||||||
849A97531ED9EAC0007D329B /* AddFeedController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 849A97511ED9EAC0007D329B /* AddFeedController.swift */; };
|
849A97531ED9EAC0007D329B /* AddFeedController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 849A97511ED9EAC0007D329B /* AddFeedController.swift */; };
|
||||||
849A97541ED9EAC0007D329B /* AddFeedWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 849A97521ED9EAC0007D329B /* AddFeedWindowController.swift */; };
|
849A97541ED9EAC0007D329B /* AddFeedWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 849A97521ED9EAC0007D329B /* AddFeedWindowController.swift */; };
|
||||||
@ -382,6 +383,7 @@
|
|||||||
846A7BEB1F872C5600FEFD30 /* BatchUpdate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = BatchUpdate.swift; path = Evergreen/BatchUpdate.swift; sourceTree = "<group>"; };
|
846A7BEB1F872C5600FEFD30 /* BatchUpdate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = BatchUpdate.swift; path = Evergreen/BatchUpdate.swift; sourceTree = "<group>"; };
|
||||||
846E77161F6EF5D000A165E2 /* Database.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = Database.xcodeproj; path = Frameworks/Database/Database.xcodeproj; sourceTree = "<group>"; };
|
846E77161F6EF5D000A165E2 /* Database.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = Database.xcodeproj; path = Frameworks/Database/Database.xcodeproj; sourceTree = "<group>"; };
|
||||||
846E77301F6EF5D600A165E2 /* Account.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = Account.xcodeproj; path = Frameworks/Account/Account.xcodeproj; sourceTree = "<group>"; };
|
846E77301F6EF5D600A165E2 /* Account.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = Account.xcodeproj; path = Frameworks/Account/Account.xcodeproj; sourceTree = "<group>"; };
|
||||||
|
84702AA31FA27AC0006B8943 /* MarkAllReadCommand.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MarkAllReadCommand.swift; sourceTree = "<group>"; };
|
||||||
849A97421ED9EAA9007D329B /* AddFolderWindowController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AddFolderWindowController.swift; sourceTree = "<group>"; };
|
849A97421ED9EAA9007D329B /* AddFolderWindowController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AddFolderWindowController.swift; sourceTree = "<group>"; };
|
||||||
849A97511ED9EAC0007D329B /* AddFeedController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = AddFeedController.swift; path = AddFeed/AddFeedController.swift; sourceTree = "<group>"; };
|
849A97511ED9EAC0007D329B /* AddFeedController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = AddFeedController.swift; path = AddFeed/AddFeedController.swift; sourceTree = "<group>"; };
|
||||||
849A97521ED9EAC0007D329B /* AddFeedWindowController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = AddFeedWindowController.swift; path = AddFeed/AddFeedWindowController.swift; sourceTree = "<group>"; };
|
849A97521ED9EAC0007D329B /* AddFeedWindowController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = AddFeedWindowController.swift; path = AddFeed/AddFeedWindowController.swift; sourceTree = "<group>"; };
|
||||||
@ -520,6 +522,14 @@
|
|||||||
name = Products;
|
name = Products;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
};
|
};
|
||||||
|
84702AB31FA27AE8006B8943 /* Commands */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
84702AA31FA27AC0006B8943 /* MarkAllReadCommand.swift */,
|
||||||
|
);
|
||||||
|
path = Commands;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
849A97411ED9EAA9007D329B /* Add Folder */ = {
|
849A97411ED9EAA9007D329B /* Add Folder */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
@ -676,6 +686,7 @@
|
|||||||
84DAEE311F870B390058304B /* DockBadge.swift */,
|
84DAEE311F870B390058304B /* DockBadge.swift */,
|
||||||
842E45DC1ED8C54B000A8B52 /* Browser.swift */,
|
842E45DC1ED8C54B000A8B52 /* Browser.swift */,
|
||||||
846A7BEB1F872C5600FEFD30 /* BatchUpdate.swift */,
|
846A7BEB1F872C5600FEFD30 /* BatchUpdate.swift */,
|
||||||
|
84702AB31FA27AE8006B8943 /* Commands */,
|
||||||
842E45E11ED8C681000A8B52 /* MainWindow */,
|
842E45E11ED8C681000A8B52 /* MainWindow */,
|
||||||
842E45E01ED8C587000A8B52 /* Preferences */,
|
842E45E01ED8C587000A8B52 /* Preferences */,
|
||||||
849A97861ED9ECEF007D329B /* Article Styles */,
|
849A97861ED9ECEF007D329B /* Article Styles */,
|
||||||
@ -1174,6 +1185,7 @@
|
|||||||
842E45E51ED8C6B7000A8B52 /* MainWindowSplitView.swift in Sources */,
|
842E45E51ED8C6B7000A8B52 /* MainWindowSplitView.swift in Sources */,
|
||||||
849A97661ED9EB96007D329B /* SidebarViewController.swift in Sources */,
|
849A97661ED9EB96007D329B /* SidebarViewController.swift in Sources */,
|
||||||
849A97641ED9EB96007D329B /* SidebarOutlineView.swift in Sources */,
|
849A97641ED9EB96007D329B /* SidebarOutlineView.swift in Sources */,
|
||||||
|
84702AA41FA27AC0006B8943 /* MarkAllReadCommand.swift in Sources */,
|
||||||
849A979F1ED9F130007D329B /* SidebarCell.swift in Sources */,
|
849A979F1ED9F130007D329B /* SidebarCell.swift in Sources */,
|
||||||
849A97651ED9EB96007D329B /* SidebarTreeControllerDelegate.swift in Sources */,
|
849A97651ED9EB96007D329B /* SidebarTreeControllerDelegate.swift in Sources */,
|
||||||
849A97671ED9EB96007D329B /* UnreadCountView.swift in Sources */,
|
849A97671ED9EB96007D329B /* UnreadCountView.swift in Sources */,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user