Change ReadFilter to ReadFilterType and differentiate the ReadFilter from the query filter.

This commit is contained in:
Maurice Parker 2019-11-22 09:40:39 -06:00
parent a5b4d570af
commit eea5d6f327
8 changed files with 17 additions and 16 deletions

View File

@ -9,7 +9,7 @@
import Foundation
import RSCore
public enum ReadFilter {
public enum ReadFilterType {
case read
case none
case alwaysRead
@ -17,6 +17,6 @@ public enum ReadFilter {
public protocol Feed: FeedIdentifiable, ArticleFetcher, DisplayNameProvider, UnreadCountProvider {
var defaultReadFilter: ReadFilter { get }
var defaultReadFilterType: ReadFilterType { get }
}

View File

@ -12,7 +12,7 @@ import RSCore
public final class Folder: Feed, Renamable, Container, Hashable {
public var defaultReadFilter: ReadFilter {
public var defaultReadFilterType: ReadFilterType {
return .read
}

View File

@ -13,7 +13,7 @@ import Articles
public final class WebFeed: Feed, Renamable, Hashable {
public var defaultReadFilter: ReadFilter {
public var defaultReadFilterType: ReadFilterType {
return .none
}

View File

@ -13,7 +13,7 @@ import Account
final class SmartFeed: PseudoFeed {
public var defaultReadFilter: ReadFilter {
public var defaultReadFilterType: ReadFilterType {
return .none
}

View File

@ -19,7 +19,7 @@ import Articles
final class UnreadFeed: PseudoFeed {
public var defaultReadFilter: ReadFilter {
public var defaultReadFilterType: ReadFilterType {
return .alwaysRead
}

View File

@ -19,13 +19,13 @@ typealias FetchRequestOperationResultBlock = (Set<Article>, FetchRequestOperatio
final class FetchRequestOperation {
let id: Int
let readFilter: ReadFilter
let readFilter: Bool
let resultBlock: FetchRequestOperationResultBlock
var isCanceled = false
var isFinished = false
private let representedObjects: [Any]
init(id: Int, readFilter: ReadFilter, representedObjects: [Any], resultBlock: @escaping FetchRequestOperationResultBlock) {
init(id: Int, readFilter: Bool, representedObjects: [Any], resultBlock: @escaping FetchRequestOperationResultBlock) {
precondition(Thread.isMainThread)
self.id = id
self.readFilter = readFilter
@ -82,7 +82,7 @@ final class FetchRequestOperation {
}
for articleFetcher in articleFetchers {
if readFilter == .read {
if readFilter {
articleFetcher.fetchUnreadArticlesAsync { (articles) in
process(articles: articles)
}

View File

@ -89,7 +89,7 @@ class MasterTimelineViewController: UITableViewController, UndoableCommandRunner
// MARK: Actions
@IBAction func toggleFilter(_ sender: Any) {
switch coordinator.articleReadFilter {
switch coordinator.articleReadFilterType {
case .none:
filterButton.image = AppAssets.filterActiveImage
coordinator.hideUnreadArticles()
@ -493,7 +493,7 @@ private extension MasterTimelineViewController {
navigationItem.titleView = titleView
}
switch coordinator.articleReadFilter {
switch coordinator.articleReadFilterType {
case .none:
filterButton.image = AppAssets.filterInactiveImage
default:

View File

@ -116,7 +116,7 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider {
return treeControllerDelegate.isUnreadFiltered
}
var articleReadFilter: ReadFilter = .none
var articleReadFilterType: ReadFilterType = .none
var rootNode: Node {
return treeController.rootNode
@ -482,12 +482,12 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider {
}
func showAllArticles() {
articleReadFilter = .none
articleReadFilterType = .none
refreshTimeline()
}
func hideUnreadArticles() {
articleReadFilter = .read
articleReadFilterType = .read
refreshTimeline()
}
@ -1150,7 +1150,7 @@ private extension SceneCoordinator {
func setTimelineFeed(_ feed: Feed?, completion: (() -> Void)? = nil) {
timelineFeed = feed
timelineMiddleIndexPath = nil
articleReadFilter = feed?.defaultReadFilter ?? .none
articleReadFilterType = feed?.defaultReadFilterType ?? .none
fetchAndReplaceArticlesAsync {
self.masterTimelineViewController?.reinitializeArticles()
@ -1491,7 +1491,8 @@ private extension SceneCoordinator {
precondition(Thread.isMainThread)
cancelPendingAsyncFetches()
let fetchOperation = FetchRequestOperation(id: fetchSerialNumber, readFilter: articleReadFilter, representedObjects: representedObjects) { [weak self] (articles, operation) in
let readFilter = articleReadFilterType != .none
let fetchOperation = FetchRequestOperation(id: fetchSerialNumber, readFilter: readFilter, representedObjects: representedObjects) { [weak self] (articles, operation) in
precondition(Thread.isMainThread)
guard !operation.isCanceled, let strongSelf = self, operation.id == strongSelf.fetchSerialNumber else {
return