Move Feed from Articles.framework to Account.framework.
This commit is contained in:
parent
b7575c687c
commit
fc338d5371
|
@ -8,6 +8,7 @@
|
|||
|
||||
import AppKit
|
||||
import Articles
|
||||
import Account
|
||||
import RSCore
|
||||
|
||||
extension Notification.Name {
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
import AppKit
|
||||
import Articles
|
||||
import Account
|
||||
import RSWeb
|
||||
import RSParser
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
import AppKit
|
||||
import Articles
|
||||
import Account
|
||||
import DB5
|
||||
|
||||
final class FeedInspectorViewController: NSViewController, Inspector {
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
import Foundation
|
||||
import RSCore
|
||||
import Articles
|
||||
import Account
|
||||
|
||||
var cachedStyleString = ""
|
||||
var cachedTemplate = ""
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
import AppKit
|
||||
import Articles
|
||||
import Account
|
||||
import RSCore
|
||||
|
||||
extension Feed: PasteboardWriterOwner {
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
import Foundation
|
||||
import Articles
|
||||
import Account
|
||||
import RSCore
|
||||
|
||||
protocol PseudoFeed: class, DisplayNameProvider, UnreadCountProvider, SmallIconProvider, PasteboardWriterOwner {
|
||||
|
|
|
@ -140,7 +140,7 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
|
|||
|
||||
feed.takeSettings(from: parsedFeed)
|
||||
|
||||
database.update(feed: feed, parsedFeed: parsedFeed) { (newArticles, updatedArticles) in
|
||||
database.update(feedID: feed.feedID, parsedFeed: parsedFeed) { (newArticles, updatedArticles) in
|
||||
|
||||
var userInfo = [String: Any]()
|
||||
if let newArticles = newArticles, !newArticles.isEmpty {
|
||||
|
@ -302,10 +302,10 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
|
|||
return
|
||||
}
|
||||
|
||||
database.fetchUnreadCounts(for: feeds) { (unreadCountDictionary) in
|
||||
database.fetchUnreadCounts(for: feeds.feedIDs()) { (unreadCountDictionary) in
|
||||
|
||||
for feed in feeds {
|
||||
if let unreadCount = unreadCountDictionary[feed] {
|
||||
if let unreadCount = unreadCountDictionary[feed.feedID] {
|
||||
feed.unreadCount = unreadCount
|
||||
}
|
||||
}
|
||||
|
@ -314,14 +314,14 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
|
|||
|
||||
public func fetchArticles(for feed: Feed) -> Set<Article> {
|
||||
|
||||
let articles = database.fetchArticles(for: feed)
|
||||
let articles = database.fetchArticles(for: feed.feedID)
|
||||
validateUnreadCount(feed, articles)
|
||||
return articles
|
||||
}
|
||||
|
||||
public func fetchUnreadArticles(for feed: Feed) -> Set<Article> {
|
||||
|
||||
let articles = database.fetchUnreadArticles(for: Set([feed]))
|
||||
let articles = database.fetchUnreadArticles(for: Set([feed.feedID]))
|
||||
validateUnreadCount(feed, articles)
|
||||
return articles
|
||||
}
|
||||
|
@ -339,19 +339,19 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
|
|||
public func fetchUnreadArticles(forContainer container: Container) -> Set<Article> {
|
||||
|
||||
let feeds = container.flattenedFeeds()
|
||||
let articles = database.fetchUnreadArticles(for: feeds)
|
||||
let articles = database.fetchUnreadArticles(for: feeds.feedIDs())
|
||||
feeds.forEach { validateUnreadCount($0, articles) }
|
||||
return articles
|
||||
}
|
||||
|
||||
public func fetchTodayArticles() -> Set<Article> {
|
||||
|
||||
return database.fetchTodayArticles(for: flattenedFeeds())
|
||||
return database.fetchTodayArticles(for: flattenedFeeds().feedIDs())
|
||||
}
|
||||
|
||||
public func fetchStarredArticles() -> Set<Article> {
|
||||
|
||||
return database.fetchStarredArticles(for: flattenedFeeds())
|
||||
return database.fetchStarredArticles(for: flattenedFeeds().feedIDs())
|
||||
}
|
||||
|
||||
private func validateUnreadCount(_ feed: Feed, _ articles: Set<Article>) {
|
||||
|
@ -372,12 +372,12 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
|
|||
public func fetchUnreadCountForToday(_ callback: @escaping (Int) -> Void) {
|
||||
|
||||
let startOfToday = NSCalendar.startOfToday()
|
||||
database.fetchUnreadCount(for: flattenedFeeds(), since: startOfToday, callback: callback)
|
||||
database.fetchUnreadCount(for: flattenedFeeds().feedIDs(), since: startOfToday, callback: callback)
|
||||
}
|
||||
|
||||
public func fetchUnreadCountForStarredArticles(_ callback: @escaping (Int) -> Void) {
|
||||
|
||||
database.fetchStarredAndUnreadCount(for: flattenedFeeds(), callback: callback)
|
||||
database.fetchStarredAndUnreadCount(for: flattenedFeeds().feedIDs(), callback: callback)
|
||||
}
|
||||
|
||||
public func markEverywhereAsRead() {
|
||||
|
@ -680,7 +680,7 @@ private extension Account {
|
|||
|
||||
// When the unread count is zero, it won’t appear in unreadCountDictionary.
|
||||
|
||||
if let unreadCount = unreadCountDictionary[feed] {
|
||||
if let unreadCount = unreadCountDictionary[feed.feedID] {
|
||||
feed.unreadCount = unreadCount
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -17,6 +17,9 @@
|
|||
84245C811FDDD42A0074AFBB /* Feedbin.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84245C801FDDD42A0074AFBB /* Feedbin.swift */; };
|
||||
84245C831FDDD8160074AFBB /* FeedbinGetSubscriptionsDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84245C821FDDD8160074AFBB /* FeedbinGetSubscriptionsDelegate.swift */; };
|
||||
84245C851FDDD8CB0074AFBB /* FeedbinSubscription.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84245C841FDDD8CB0074AFBB /* FeedbinSubscription.swift */; };
|
||||
844B297D2106C7EC004020B3 /* Feed.swift in Sources */ = {isa = PBXBuildFile; fileRef = 844B297C2106C7EC004020B3 /* Feed.swift */; };
|
||||
844B297F210CE37E004020B3 /* UnreadCountProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 844B297E210CE37E004020B3 /* UnreadCountProvider.swift */; };
|
||||
844B2981210CE3BF004020B3 /* RSWeb.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 844B2980210CE3BF004020B3 /* RSWeb.framework */; };
|
||||
8469F81C1F6DD15E0084783E /* Account.swift in Sources */ = {isa = PBXBuildFile; fileRef = 848935101F62486800CEBD24 /* Account.swift */; };
|
||||
846E77451F6EF9B900A165E2 /* Container.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8419740D1F6DD25F006346C4 /* Container.swift */; };
|
||||
846E774F1F6EF9C000A165E2 /* LocalAccountDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8419742C1F6DDE84006346C4 /* LocalAccountDelegate.swift */; };
|
||||
|
@ -120,6 +123,9 @@
|
|||
84245C801FDDD42A0074AFBB /* Feedbin.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Feedbin.swift; sourceTree = "<group>"; };
|
||||
84245C821FDDD8160074AFBB /* FeedbinGetSubscriptionsDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeedbinGetSubscriptionsDelegate.swift; sourceTree = "<group>"; };
|
||||
84245C841FDDD8CB0074AFBB /* FeedbinSubscription.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeedbinSubscription.swift; sourceTree = "<group>"; };
|
||||
844B297C2106C7EC004020B3 /* Feed.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Feed.swift; sourceTree = "<group>"; };
|
||||
844B297E210CE37E004020B3 /* UnreadCountProvider.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UnreadCountProvider.swift; sourceTree = "<group>"; };
|
||||
844B2980210CE3BF004020B3 /* RSWeb.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = RSWeb.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
846E77531F6F00E300A165E2 /* AccountManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountManager.swift; sourceTree = "<group>"; };
|
||||
848934F61F62484F00CEBD24 /* Account.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Account.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
848934FA1F62484F00CEBD24 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
|
@ -144,6 +150,7 @@
|
|||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
844B2981210CE3BF004020B3 /* RSWeb.framework in Frameworks */,
|
||||
841D4D722106B40A00DD04E6 /* Articles.framework in Frameworks */,
|
||||
841D4D702106B40400DD04E6 /* ArticlesDatabase.framework in Frameworks */,
|
||||
841973FE1F6DD1BC006346C4 /* RSCore.framework in Frameworks */,
|
||||
|
@ -223,6 +230,7 @@
|
|||
8469F80F1F6DC3C10084783E /* Frameworks */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
844B2980210CE3BF004020B3 /* RSWeb.framework */,
|
||||
841D4D712106B40A00DD04E6 /* Articles.framework */,
|
||||
841D4D6F2106B40400DD04E6 /* ArticlesDatabase.framework */,
|
||||
8401A1721F6DC387002B1BE2 /* Database.xcodeproj */,
|
||||
|
@ -240,6 +248,8 @@
|
|||
848935101F62486800CEBD24 /* Account.swift */,
|
||||
841974241F6DDCE4006346C4 /* AccountDelegate.swift */,
|
||||
841974001F6DD1EC006346C4 /* Folder.swift */,
|
||||
844B297C2106C7EC004020B3 /* Feed.swift */,
|
||||
844B297E210CE37E004020B3 /* UnreadCountProvider.swift */,
|
||||
84B99C9E1FAE8D3200ECDEDB /* ContainerPath.swift */,
|
||||
84C365491F899F3B001EC85C /* CombinedRefreshProgress.swift */,
|
||||
84C8B3F31F89DE430053CCA6 /* DataExtensions.swift */,
|
||||
|
@ -487,12 +497,14 @@
|
|||
84245C7F1FDDD2580074AFBB /* FeedbinAccountDelegate.swift in Sources */,
|
||||
841974251F6DDCE4006346C4 /* AccountDelegate.swift in Sources */,
|
||||
846E77541F6F00E300A165E2 /* AccountManager.swift in Sources */,
|
||||
844B297D2106C7EC004020B3 /* Feed.swift in Sources */,
|
||||
84B99C9F1FAE8D3200ECDEDB /* ContainerPath.swift in Sources */,
|
||||
846E77501F6EF9C400A165E2 /* LocalAccountRefresher.swift in Sources */,
|
||||
84245C811FDDD42A0074AFBB /* Feedbin.swift in Sources */,
|
||||
84CAD7161FDF2E22000F0755 /* FeedbinArticle.swift in Sources */,
|
||||
841974011F6DD1EC006346C4 /* Folder.swift in Sources */,
|
||||
846E774F1F6EF9C000A165E2 /* LocalAccountDelegate.swift in Sources */,
|
||||
844B297F210CE37E004020B3 /* UnreadCountProvider.swift in Sources */,
|
||||
84245C851FDDD8CB0074AFBB /* FeedbinSubscription.swift in Sources */,
|
||||
84245C831FDDD8160074AFBB /* FeedbinGetSubscriptionsDelegate.swift in Sources */,
|
||||
);
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
import Foundation
|
||||
import RSCore
|
||||
import RSWeb
|
||||
import Articles
|
||||
|
||||
public final class Feed: DisplayNameProvider, UnreadCountProvider, Hashable {
|
||||
|
||||
|
@ -189,3 +190,10 @@ extension Feed: OPMLRepresentable {
|
|||
}
|
||||
}
|
||||
|
||||
extension Set where Element == Feed {
|
||||
|
||||
func feedIDs() -> Set<String> {
|
||||
|
||||
return Set<String>(map { $0.feedID })
|
||||
}
|
||||
}
|
|
@ -8,16 +8,13 @@
|
|||
|
||||
/* Begin PBXBuildFile section */
|
||||
840405CA1F1A8E4300DF0296 /* DatabaseID.swift in Sources */ = {isa = PBXBuildFile; fileRef = 840405C91F1A8E4300DF0296 /* DatabaseID.swift */; };
|
||||
8419741C1F6DD613006346C4 /* UnreadCountProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8419741B1F6DD613006346C4 /* UnreadCountProvider.swift */; };
|
||||
844BEE651F0AB3C9004AB7CD /* Articles.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 844BEE5B1F0AB3C8004AB7CD /* Articles.framework */; };
|
||||
844BEE6A1F0AB3C9004AB7CD /* DataTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 844BEE691F0AB3C9004AB7CD /* DataTests.swift */; };
|
||||
844BEE7D1F0AB4C4004AB7CD /* Feed.swift in Sources */ = {isa = PBXBuildFile; fileRef = 844BEE7C1F0AB4C4004AB7CD /* Feed.swift */; };
|
||||
844BEE7F1F0AB4CA004AB7CD /* Article.swift in Sources */ = {isa = PBXBuildFile; fileRef = 844BEE7E1F0AB4CA004AB7CD /* Article.swift */; };
|
||||
844BEE811F0AB4D0004AB7CD /* Author.swift in Sources */ = {isa = PBXBuildFile; fileRef = 844BEE801F0AB4D0004AB7CD /* Author.swift */; };
|
||||
844BEE831F0AB4D6004AB7CD /* Attachment.swift in Sources */ = {isa = PBXBuildFile; fileRef = 844BEE821F0AB4D6004AB7CD /* Attachment.swift */; };
|
||||
844BEE851F0AB4DB004AB7CD /* ArticleStatus.swift in Sources */ = {isa = PBXBuildFile; fileRef = 844BEE841F0AB4DB004AB7CD /* ArticleStatus.swift */; };
|
||||
848E3EB420FBCFAE0004B7ED /* RSCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 848E3EB320FBCFAE0004B7ED /* RSCore.framework */; };
|
||||
848E3EB520FBCFB50004B7ED /* RSWeb.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 84C490F51F705D5F003131D2 /* RSWeb.framework */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXContainerItemProxy section */
|
||||
|
@ -53,13 +50,11 @@
|
|||
|
||||
/* Begin PBXFileReference section */
|
||||
840405C91F1A8E4300DF0296 /* DatabaseID.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DatabaseID.swift; sourceTree = "<group>"; };
|
||||
8419741B1F6DD613006346C4 /* UnreadCountProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UnreadCountProvider.swift; sourceTree = "<group>"; };
|
||||
844BEE5B1F0AB3C8004AB7CD /* Articles.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Articles.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
844BEE641F0AB3C9004AB7CD /* ArticlesTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ArticlesTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
844BEE691F0AB3C9004AB7CD /* DataTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DataTests.swift; sourceTree = "<group>"; };
|
||||
844BEE6B1F0AB3C9004AB7CD /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
844BEE761F0AB444004AB7CD /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
844BEE7C1F0AB4C4004AB7CD /* Feed.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Feed.swift; sourceTree = "<group>"; };
|
||||
844BEE7E1F0AB4CA004AB7CD /* Article.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Article.swift; sourceTree = "<group>"; };
|
||||
844BEE801F0AB4D0004AB7CD /* Author.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Author.swift; sourceTree = "<group>"; };
|
||||
844BEE821F0AB4D6004AB7CD /* Attachment.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Attachment.swift; sourceTree = "<group>"; };
|
||||
|
@ -79,7 +74,6 @@
|
|||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
848E3EB520FBCFB50004B7ED /* RSWeb.framework in Frameworks */,
|
||||
848E3EB420FBCFAE0004B7ED /* RSCore.framework in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
|
@ -98,13 +92,11 @@
|
|||
844BEE511F0AB3C8004AB7CD = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
844BEE7C1F0AB4C4004AB7CD /* Feed.swift */,
|
||||
844BEE7E1F0AB4CA004AB7CD /* Article.swift */,
|
||||
844BEE801F0AB4D0004AB7CD /* Author.swift */,
|
||||
844BEE821F0AB4D6004AB7CD /* Attachment.swift */,
|
||||
844BEE841F0AB4DB004AB7CD /* ArticleStatus.swift */,
|
||||
840405C91F1A8E4300DF0296 /* DatabaseID.swift */,
|
||||
8419741B1F6DD613006346C4 /* UnreadCountProvider.swift */,
|
||||
844BEE761F0AB444004AB7CD /* Info.plist */,
|
||||
844BEE681F0AB3C9004AB7CD /* DataTests */,
|
||||
844BEE5C1F0AB3C8004AB7CD /* Products */,
|
||||
|
@ -306,9 +298,7 @@
|
|||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
844BEE7F1F0AB4CA004AB7CD /* Article.swift in Sources */,
|
||||
844BEE7D1F0AB4C4004AB7CD /* Feed.swift in Sources */,
|
||||
844BEE831F0AB4D6004AB7CD /* Attachment.swift in Sources */,
|
||||
8419741C1F6DD613006346C4 /* UnreadCountProvider.swift in Sources */,
|
||||
844BEE811F0AB4D0004AB7CD /* Author.swift in Sources */,
|
||||
840405CA1F1A8E4300DF0296 /* DatabaseID.swift in Sources */,
|
||||
844BEE851F0AB4DB004AB7CD /* ArticleStatus.swift in Sources */,
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
//
|
||||
|
||||
import Foundation
|
||||
import RSCore
|
||||
|
||||
public struct Author: Hashable {
|
||||
|
||||
|
@ -82,7 +81,7 @@ public struct Author: Hashable {
|
|||
return lhs.hashValue == rhs.hashValue && lhs.authorID == rhs.authorID
|
||||
}
|
||||
|
||||
static func authorsWithDiskArray(_ diskArray: [[String: Any]]) -> Set<Author>? {
|
||||
public static func authorsWithDiskArray(_ diskArray: [[String: Any]]) -> Set<Author>? {
|
||||
|
||||
let authors = diskArray.compactMap { Author(dictionary: $0) }
|
||||
return authors.isEmpty ? nil : Set(authors)
|
||||
|
@ -91,7 +90,7 @@ public struct Author: Hashable {
|
|||
|
||||
extension Set where Element == Author {
|
||||
|
||||
func diskArray() -> [[String: Any]]? {
|
||||
public func diskArray() -> [[String: Any]]? {
|
||||
|
||||
if self.isEmpty {
|
||||
return nil
|
||||
|
|
|
@ -42,46 +42,46 @@ public final class ArticlesDatabase {
|
|||
|
||||
// MARK: - Fetching Articles
|
||||
|
||||
public func fetchArticles(for feed: Feed) -> Set<Article> {
|
||||
public func fetchArticles(for feedID: String) -> Set<Article> {
|
||||
|
||||
return articlesTable.fetchArticles(feed)
|
||||
return articlesTable.fetchArticles(feedID)
|
||||
}
|
||||
|
||||
public func fetchArticlesAsync(for feed: Feed, _ resultBlock: @escaping ArticleResultBlock) {
|
||||
public func fetchArticlesAsync(for feedID: String, _ resultBlock: @escaping ArticleResultBlock) {
|
||||
|
||||
articlesTable.fetchArticlesAsync(feed, withLimits: true, resultBlock)
|
||||
articlesTable.fetchArticlesAsync(feedID, withLimits: true, resultBlock)
|
||||
}
|
||||
|
||||
public func fetchUnreadArticles(for feeds: Set<Feed>) -> Set<Article> {
|
||||
public func fetchUnreadArticles(for feedIDs: Set<String>) -> Set<Article> {
|
||||
|
||||
return articlesTable.fetchUnreadArticles(for: feeds)
|
||||
return articlesTable.fetchUnreadArticles(for: feedIDs)
|
||||
}
|
||||
|
||||
public func fetchTodayArticles(for feeds: Set<Feed>) -> Set<Article> {
|
||||
public func fetchTodayArticles(for feedIDs: Set<String>) -> Set<Article> {
|
||||
|
||||
return articlesTable.fetchTodayArticles(for: feeds)
|
||||
return articlesTable.fetchTodayArticles(for: feedIDs)
|
||||
}
|
||||
|
||||
public func fetchStarredArticles(for feeds: Set<Feed>) -> Set<Article> {
|
||||
public func fetchStarredArticles(for feedIDs: Set<String>) -> Set<Article> {
|
||||
|
||||
return articlesTable.fetchStarredArticles(for: feeds)
|
||||
return articlesTable.fetchStarredArticles(for: feedIDs)
|
||||
}
|
||||
|
||||
// MARK: - Unread Counts
|
||||
|
||||
public func fetchUnreadCounts(for feeds: Set<Feed>, _ completion: @escaping UnreadCountCompletionBlock) {
|
||||
public func fetchUnreadCounts(for feedIDs: Set<String>, _ completion: @escaping UnreadCountCompletionBlock) {
|
||||
|
||||
articlesTable.fetchUnreadCounts(feeds, completion)
|
||||
articlesTable.fetchUnreadCounts(feedIDs, completion)
|
||||
}
|
||||
|
||||
public func fetchUnreadCount(for feeds: Set<Feed>, since: Date, callback: @escaping (Int) -> Void) {
|
||||
public func fetchUnreadCount(for feedIDs: Set<String>, since: Date, callback: @escaping (Int) -> Void) {
|
||||
|
||||
articlesTable.fetchUnreadCount(feeds, since, callback)
|
||||
articlesTable.fetchUnreadCount(feedIDs, since, callback)
|
||||
}
|
||||
|
||||
public func fetchStarredAndUnreadCount(for feeds: Set<Feed>, callback: @escaping (Int) -> Void) {
|
||||
public func fetchStarredAndUnreadCount(for feedIDs: Set<String>, callback: @escaping (Int) -> Void) {
|
||||
|
||||
articlesTable.fetchStarredAndUnreadCount(feeds, callback)
|
||||
articlesTable.fetchStarredAndUnreadCount(feedIDs, callback)
|
||||
}
|
||||
|
||||
public func fetchAllNonZeroUnreadCounts(_ completion: @escaping UnreadCountCompletionBlock) {
|
||||
|
@ -91,9 +91,9 @@ public final class ArticlesDatabase {
|
|||
|
||||
// MARK: - Saving and Updating Articles
|
||||
|
||||
public func update(feed: Feed, parsedFeed: ParsedFeed, completion: @escaping UpdateArticlesWithFeedCompletionBlock) {
|
||||
public func update(feedID: String, parsedFeed: ParsedFeed, completion: @escaping UpdateArticlesWithFeedCompletionBlock) {
|
||||
|
||||
return articlesTable.update(feed, parsedFeed, completion)
|
||||
return articlesTable.update(feedID, parsedFeed, completion)
|
||||
}
|
||||
|
||||
// MARK: - Status
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
845580761F0AF670003CCFA1 /* Article+Database.swift in Sources */ = {isa = PBXBuildFile; fileRef = 845580751F0AF670003CCFA1 /* Article+Database.swift */; };
|
||||
8455807A1F0AF67D003CCFA1 /* ArticleStatus+Database.swift in Sources */ = {isa = PBXBuildFile; fileRef = 845580791F0AF67D003CCFA1 /* ArticleStatus+Database.swift */; };
|
||||
8455807C1F0C0DBD003CCFA1 /* Attachment+Database.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8455807B1F0C0DBD003CCFA1 /* Attachment+Database.swift */; };
|
||||
846FB36B1F4A937B00EAB81D /* Feed+Database.swift in Sources */ = {isa = PBXBuildFile; fileRef = 846FB36A1F4A937B00EAB81D /* Feed+Database.swift */; };
|
||||
848AD2961F58A91E004FB0EC /* UnreadCountDictionary.swift in Sources */ = {isa = PBXBuildFile; fileRef = 848AD2951F58A91E004FB0EC /* UnreadCountDictionary.swift */; };
|
||||
848E3EB920FBCFD20004B7ED /* RSCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 848E3EB820FBCFD20004B7ED /* RSCore.framework */; };
|
||||
848E3EBB20FBCFD80004B7ED /* RSParser.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 848E3EBA20FBCFD80004B7ED /* RSParser.framework */; };
|
||||
|
@ -130,7 +129,6 @@
|
|||
845580791F0AF67D003CCFA1 /* ArticleStatus+Database.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "ArticleStatus+Database.swift"; path = "Extensions/ArticleStatus+Database.swift"; sourceTree = "<group>"; };
|
||||
8455807B1F0C0DBD003CCFA1 /* Attachment+Database.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "Attachment+Database.swift"; path = "Extensions/Attachment+Database.swift"; sourceTree = "<group>"; };
|
||||
8461461E1F0ABC7300870CB3 /* RSParser.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RSParser.xcodeproj; path = ../RSParser/RSParser.xcodeproj; sourceTree = "<group>"; };
|
||||
846FB36A1F4A937B00EAB81D /* Feed+Database.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = "Feed+Database.swift"; path = "Extensions/Feed+Database.swift"; sourceTree = "<group>"; };
|
||||
848AD2951F58A91E004FB0EC /* UnreadCountDictionary.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UnreadCountDictionary.swift; sourceTree = "<group>"; };
|
||||
848E3EB820FBCFD20004B7ED /* RSCore.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = RSCore.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
848E3EBA20FBCFD80004B7ED /* RSParser.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = RSParser.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
|
@ -227,7 +225,6 @@
|
|||
8461462A1F0AC44100870CB3 /* Extensions */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
846FB36A1F4A937B00EAB81D /* Feed+Database.swift */,
|
||||
845580751F0AF670003CCFA1 /* Article+Database.swift */,
|
||||
843702C21F70D15D00B18807 /* ParsedArticle+Database.swift */,
|
||||
845580791F0AF67D003CCFA1 /* ArticleStatus+Database.swift */,
|
||||
|
@ -500,7 +497,6 @@
|
|||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
845580671F0AEBCD003CCFA1 /* Constants.swift in Sources */,
|
||||
846FB36B1F4A937B00EAB81D /* Feed+Database.swift in Sources */,
|
||||
843CB9961F34174100EE6581 /* Author+Database.swift in Sources */,
|
||||
848AD2961F58A91E004FB0EC /* UnreadCountDictionary.swift in Sources */,
|
||||
845580761F0AF670003CCFA1 /* Article+Database.swift in Sources */,
|
||||
|
|
|
@ -41,9 +41,8 @@ final class ArticlesTable: DatabaseTable {
|
|||
|
||||
// MARK: Fetching
|
||||
|
||||
func fetchArticles(_ feed: Feed) -> Set<Article> {
|
||||
func fetchArticles(_ feedID: String) -> Set<Article> {
|
||||
|
||||
let feedID = feed.feedID
|
||||
var articles = Set<Article>()
|
||||
|
||||
queue.fetchSync { (database) in
|
||||
|
@ -53,9 +52,7 @@ final class ArticlesTable: DatabaseTable {
|
|||
return articles
|
||||
}
|
||||
|
||||
func fetchArticlesAsync(_ feed: Feed, withLimits: Bool, _ resultBlock: @escaping ArticleResultBlock) {
|
||||
|
||||
let feedID = feed.feedID
|
||||
func fetchArticlesAsync(_ feedID: String, withLimits: Bool, _ resultBlock: @escaping ArticleResultBlock) {
|
||||
|
||||
queue.fetch { (database) in
|
||||
|
||||
|
@ -67,24 +64,24 @@ final class ArticlesTable: DatabaseTable {
|
|||
}
|
||||
}
|
||||
|
||||
func fetchUnreadArticles(for feeds: Set<Feed>) -> Set<Article> {
|
||||
func fetchUnreadArticles(for feedIDs: Set<String>) -> Set<Article> {
|
||||
|
||||
return fetchUnreadArticles(feeds.feedIDs())
|
||||
return fetchUnreadArticles(feedIDs)
|
||||
}
|
||||
|
||||
public func fetchTodayArticles(for feeds: Set<Feed>) -> Set<Article> {
|
||||
public func fetchTodayArticles(for feedIDs: Set<String>) -> Set<Article> {
|
||||
|
||||
return fetchTodayArticles(feeds.feedIDs())
|
||||
return fetchTodayArticles(feedIDs)
|
||||
}
|
||||
|
||||
public func fetchStarredArticles(for feeds: Set<Feed>) -> Set<Article> {
|
||||
public func fetchStarredArticles(for feedIDs: Set<String>) -> Set<Article> {
|
||||
|
||||
return fetchStarredArticles(feeds.feedIDs())
|
||||
return fetchStarredArticles(feedIDs)
|
||||
}
|
||||
|
||||
// MARK: Updating
|
||||
|
||||
func update(_ feed: Feed, _ parsedFeed: ParsedFeed, _ completion: @escaping UpdateArticlesWithFeedCompletionBlock) {
|
||||
func update(_ feedID: String, _ parsedFeed: ParsedFeed, _ completion: @escaping UpdateArticlesWithFeedCompletionBlock) {
|
||||
|
||||
if parsedFeed.items.isEmpty {
|
||||
completion(nil, nil)
|
||||
|
@ -99,7 +96,6 @@ final class ArticlesTable: DatabaseTable {
|
|||
// 6. Create array of updated Articles and save what’s changed.
|
||||
// 7. Call back with new and updated Articles.
|
||||
|
||||
let feedID = feed.feedID
|
||||
let articleIDs = Set(parsedFeed.items.map { $0.articleID })
|
||||
|
||||
self.queue.update { (database) in
|
||||
|
@ -131,14 +127,13 @@ final class ArticlesTable: DatabaseTable {
|
|||
|
||||
// MARK: Unread Counts
|
||||
|
||||
func fetchUnreadCounts(_ feeds: Set<Feed>, _ completion: @escaping UnreadCountCompletionBlock) {
|
||||
func fetchUnreadCounts(_ feedIDs: Set<String>, _ completion: @escaping UnreadCountCompletionBlock) {
|
||||
|
||||
if feeds.isEmpty {
|
||||
if feedIDs.isEmpty {
|
||||
completion(UnreadCountDictionary())
|
||||
return
|
||||
}
|
||||
|
||||
let feedIDs = feeds.feedIDs()
|
||||
var unreadCountDictionary = UnreadCountDictionary()
|
||||
|
||||
queue.fetch { (database) in
|
||||
|
@ -153,16 +148,15 @@ final class ArticlesTable: DatabaseTable {
|
|||
}
|
||||
}
|
||||
|
||||
func fetchUnreadCount(_ feeds: Set<Feed>, _ since: Date, _ callback: @escaping (Int) -> Void) {
|
||||
func fetchUnreadCount(_ feedIDs: Set<String>, _ since: Date, _ callback: @escaping (Int) -> Void) {
|
||||
|
||||
// Get unread count for today, for instance.
|
||||
|
||||
if feeds.isEmpty {
|
||||
if feedIDs.isEmpty {
|
||||
callback(0)
|
||||
return
|
||||
}
|
||||
|
||||
let feedIDs = feeds.feedIDs()
|
||||
queue.fetch { (database) in
|
||||
|
||||
let placeholders = NSString.rs_SQLValueList(withPlaceholders: UInt(feedIDs.count))!
|
||||
|
@ -211,14 +205,13 @@ final class ArticlesTable: DatabaseTable {
|
|||
}
|
||||
}
|
||||
|
||||
func fetchStarredAndUnreadCount(_ feeds: Set<Feed>, _ callback: @escaping (Int) -> Void) {
|
||||
func fetchStarredAndUnreadCount(_ feedIDs: Set<String>, _ callback: @escaping (Int) -> Void) {
|
||||
|
||||
if feeds.isEmpty {
|
||||
if feedIDs.isEmpty {
|
||||
callback(0)
|
||||
return
|
||||
}
|
||||
|
||||
let feedIDs = feeds.feedIDs()
|
||||
queue.fetch { (database) in
|
||||
|
||||
let placeholders = NSString.rs_SQLValueList(withPlaceholders: UInt(feedIDs.count))!
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
//
|
||||
// Feed+Database.swift
|
||||
// Database
|
||||
//
|
||||
// Created by Brent Simmons on 8/20/17.
|
||||
// Copyright © 2017 Ranchero Software. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import Articles
|
||||
|
||||
extension Set where Element == Feed {
|
||||
|
||||
func feedIDs() -> Set<String> {
|
||||
|
||||
return Set<String>(map { $0.feedID })
|
||||
}
|
||||
}
|
|
@ -17,7 +17,7 @@ public struct UnreadCountDictionary {
|
|||
return dictionary.count < 1
|
||||
}
|
||||
|
||||
subscript(_ feedID: String) -> Int? {
|
||||
public subscript(_ feedID: String) -> Int? {
|
||||
get {
|
||||
return dictionary[feedID]
|
||||
}
|
||||
|
@ -25,8 +25,4 @@ public struct UnreadCountDictionary {
|
|||
dictionary[feedID] = newValue
|
||||
}
|
||||
}
|
||||
|
||||
public subscript(_ feed: Feed) -> Int? {
|
||||
return dictionary[feed.feedID]
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue