mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
Remove dead code so that it doesn't confuse new developers
This commit is contained in:
@@ -836,43 +836,35 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
|
||||
/// Mark articleIDs statuses based on statusKey and flag.
|
||||
/// Will create statuses in the database and in memory as needed. Sends a .StatusesDidChange notification.
|
||||
/// Returns a set of new article statuses.
|
||||
func markAndFetchNew(articleIDs: Set<String>, statusKey: ArticleStatus.Key, flag: Bool, completion: ArticleIDsCompletionBlock? = nil) {
|
||||
func markAndFetchNew(articleIDs: Set<String>, statusKey: ArticleStatus.Key, flag: Bool, completion: DatabaseCompletionBlock? = nil) {
|
||||
guard !articleIDs.isEmpty else {
|
||||
completion?(.success(Set<String>()))
|
||||
completion?(nil)
|
||||
return
|
||||
}
|
||||
database.markAndFetchNew(articleIDs: articleIDs, statusKey: statusKey, flag: flag) { result in
|
||||
switch result {
|
||||
case .success(let newArticleStatusIDs):
|
||||
self.noteStatusesForArticleIDsDidChange(articleIDs: articleIDs, statusKey: statusKey, flag: flag)
|
||||
completion?(.success(newArticleStatusIDs))
|
||||
case .failure(let databaseError):
|
||||
completion?(.failure(databaseError))
|
||||
}
|
||||
}
|
||||
database.mark(articleIDs: articleIDs, statusKey: statusKey, flag: flag, completion: completion)
|
||||
}
|
||||
|
||||
/// Mark articleIDs as read. Will create statuses in the database and in memory as needed. Sends a .StatusesDidChange notification.
|
||||
/// Returns a set of new article statuses.
|
||||
func markAsRead(_ articleIDs: Set<String>, completion: ArticleIDsCompletionBlock? = nil) {
|
||||
func markAsRead(_ articleIDs: Set<String>, completion: DatabaseCompletionBlock? = nil) {
|
||||
markAndFetchNew(articleIDs: articleIDs, statusKey: .read, flag: true, completion: completion)
|
||||
}
|
||||
|
||||
/// Mark articleIDs as unread. Will create statuses in the database and in memory as needed. Sends a .StatusesDidChange notification.
|
||||
/// Returns a set of new article statuses.
|
||||
func markAsUnread(_ articleIDs: Set<String>, completion: ArticleIDsCompletionBlock? = nil) {
|
||||
func markAsUnread(_ articleIDs: Set<String>, completion: DatabaseCompletionBlock? = nil) {
|
||||
markAndFetchNew(articleIDs: articleIDs, statusKey: .read, flag: false, completion: completion)
|
||||
}
|
||||
|
||||
/// Mark articleIDs as starred. Will create statuses in the database and in memory as needed. Sends a .StatusesDidChange notification.
|
||||
/// Returns a set of new article statuses.
|
||||
func markAsStarred(_ articleIDs: Set<String>, completion: ArticleIDsCompletionBlock? = nil) {
|
||||
func markAsStarred(_ articleIDs: Set<String>, completion: DatabaseCompletionBlock? = nil) {
|
||||
markAndFetchNew(articleIDs: articleIDs, statusKey: .starred, flag: true, completion: completion)
|
||||
}
|
||||
|
||||
/// Mark articleIDs as unstarred. Will create statuses in the database and in memory as needed. Sends a .StatusesDidChange notification.
|
||||
/// Returns a set of new article statuses.
|
||||
func markAsUnstarred(_ articleIDs: Set<String>, completion: ArticleIDsCompletionBlock? = nil) {
|
||||
func markAsUnstarred(_ articleIDs: Set<String>, completion: DatabaseCompletionBlock? = nil) {
|
||||
markAndFetchNew(articleIDs: articleIDs, statusKey: .starred, flag: false, completion: completion)
|
||||
}
|
||||
|
||||
|
||||
@@ -96,8 +96,8 @@ private extension CloudKitArticlesZoneDelegate {
|
||||
let group = DispatchGroup()
|
||||
|
||||
group.enter()
|
||||
account?.markAsUnread(updateableUnreadArticleIDs) { result in
|
||||
if case .failure(let databaseError) = result {
|
||||
account?.markAsUnread(updateableUnreadArticleIDs) { databaseError in
|
||||
if let databaseError = databaseError {
|
||||
errorOccurred = true
|
||||
self.logger.error("Error occurred while storing unread statuses: \(databaseError.localizedDescription, privacy: .public)")
|
||||
}
|
||||
@@ -105,8 +105,8 @@ private extension CloudKitArticlesZoneDelegate {
|
||||
}
|
||||
|
||||
group.enter()
|
||||
account?.markAsRead(updateableReadArticleIDs) { result in
|
||||
if case .failure(let databaseError) = result {
|
||||
account?.markAsRead(updateableReadArticleIDs) { databaseError in
|
||||
if let databaseError = databaseError {
|
||||
errorOccurred = true
|
||||
self.logger.error("Error occurred while storing read statuses: \(databaseError.localizedDescription, privacy: .public)")
|
||||
}
|
||||
@@ -114,8 +114,8 @@ private extension CloudKitArticlesZoneDelegate {
|
||||
}
|
||||
|
||||
group.enter()
|
||||
account?.markAsUnstarred(updateableUnstarredArticleIDs) { result in
|
||||
if case .failure(let databaseError) = result {
|
||||
account?.markAsUnstarred(updateableUnstarredArticleIDs) { databaseError in
|
||||
if let databaseError = databaseError {
|
||||
errorOccurred = true
|
||||
self.logger.error("Error occurred while storing unstarred statuses: \(databaseError.localizedDescription, privacy: .public)")
|
||||
}
|
||||
@@ -123,8 +123,8 @@ private extension CloudKitArticlesZoneDelegate {
|
||||
}
|
||||
|
||||
group.enter()
|
||||
account?.markAsStarred(updateableStarredArticleIDs) { result in
|
||||
if case .failure(let databaseError) = result {
|
||||
account?.markAsStarred(updateableStarredArticleIDs) { databaseError in
|
||||
if let databaseError = databaseError {
|
||||
errorOccurred = true
|
||||
self.logger.error("Error occurred while stroing starred records: \(databaseError.localizedDescription, privacy: .public)")
|
||||
}
|
||||
|
||||
@@ -123,18 +123,18 @@ final class FeedlyIngestStarredArticleIdsOperation: FeedlyOperation, Logging {
|
||||
let results = StarredStatusResults()
|
||||
|
||||
group.enter()
|
||||
account.markAsStarred(remoteStarredArticleIDs) { result in
|
||||
if case .failure(let error) = result {
|
||||
results.markAsStarredError = error
|
||||
account.markAsStarred(remoteStarredArticleIDs) { databaseError in
|
||||
if let databaseError = databaseError {
|
||||
results.markAsStarredError = databaseError
|
||||
}
|
||||
group.leave()
|
||||
}
|
||||
|
||||
let deltaUnstarredArticleIDs = localStarredArticleIDs.subtracting(remoteStarredArticleIDs)
|
||||
group.enter()
|
||||
account.markAsUnstarred(deltaUnstarredArticleIDs) { result in
|
||||
if case .failure(let error) = result {
|
||||
results.markAsUnstarredError = error
|
||||
account.markAsUnstarred(deltaUnstarredArticleIDs) { databaseError in
|
||||
if let databaseError = databaseError {
|
||||
results.markAsUnstarredError = databaseError
|
||||
}
|
||||
group.leave()
|
||||
}
|
||||
|
||||
@@ -123,18 +123,18 @@ final class FeedlyIngestUnreadArticleIdsOperation: FeedlyOperation, Logging {
|
||||
let results = ReadStatusResults()
|
||||
|
||||
group.enter()
|
||||
account.markAsUnread(remoteUnreadArticleIDs) { result in
|
||||
if case .failure(let error) = result {
|
||||
results.markAsUnreadError = error
|
||||
account.markAsUnread(remoteUnreadArticleIDs) { databaseError in
|
||||
if let databaseError = databaseError {
|
||||
results.markAsUnreadError = databaseError
|
||||
}
|
||||
group.leave()
|
||||
}
|
||||
|
||||
let articleIDsToMarkRead = localUnreadArticleIDs.subtracting(remoteUnreadArticleIDs)
|
||||
group.enter()
|
||||
account.markAsRead(articleIDsToMarkRead) { result in
|
||||
if case .failure(let error) = result {
|
||||
results.markAsReadError = error
|
||||
account.markAsRead(articleIDsToMarkRead) { databaseError in
|
||||
if let databaseError = databaseError {
|
||||
results.markAsReadError = databaseError
|
||||
}
|
||||
group.leave()
|
||||
}
|
||||
|
||||
@@ -245,8 +245,8 @@ public final class ArticlesDatabase {
|
||||
return articlesTable.mark(articles, statusKey, flag, completion)
|
||||
}
|
||||
|
||||
public func markAndFetchNew(articleIDs: Set<String>, statusKey: ArticleStatus.Key, flag: Bool, completion: @escaping ArticleIDsCompletionBlock) {
|
||||
articlesTable.markAndFetchNew(articleIDs, statusKey, flag, completion)
|
||||
public func mark(articleIDs: Set<String>, statusKey: ArticleStatus.Key, flag: Bool, completion: DatabaseCompletionBlock?) {
|
||||
articlesTable.mark(articleIDs, statusKey, flag, completion)
|
||||
}
|
||||
|
||||
/// Create statuses for specified articleIDs. For existing statuses, don’t do anything.
|
||||
|
||||
@@ -217,7 +217,7 @@ final class ArticlesTable: DatabaseTable {
|
||||
func makeDatabaseCalls(_ database: FMDatabase) {
|
||||
let articleIDs = parsedItems.articleIDs()
|
||||
|
||||
let (statusesDictionary, _) = self.statusesTable.ensureStatusesForArticleIDs(articleIDs, false, database) //1
|
||||
let statusesDictionary = self.statusesTable.ensureStatusesForArticleIDs(articleIDs, false, database) //1
|
||||
assert(statusesDictionary.count == articleIDs.count)
|
||||
|
||||
let incomingArticles = Article.articlesWithParsedItems(parsedItems, webFeedID, self.accountID, statusesDictionary) //2
|
||||
@@ -299,7 +299,7 @@ final class ArticlesTable: DatabaseTable {
|
||||
articleIDs.formUnion(parsedItems.articleIDs())
|
||||
}
|
||||
|
||||
let (statusesDictionary, _) = self.statusesTable.ensureStatusesForArticleIDs(articleIDs, read, database) //1
|
||||
let statusesDictionary = self.statusesTable.ensureStatusesForArticleIDs(articleIDs, read, database) //1
|
||||
assert(statusesDictionary.count == articleIDs.count)
|
||||
|
||||
let allIncomingArticles = Article.articlesWithWebFeedIDsAndItems(webFeedIDsAndItems, self.accountID, statusesDictionary) //2
|
||||
@@ -472,17 +472,17 @@ final class ArticlesTable: DatabaseTable {
|
||||
}
|
||||
}
|
||||
|
||||
func markAndFetchNew(_ articleIDs: Set<String>, _ statusKey: ArticleStatus.Key, _ flag: Bool, _ completion: @escaping ArticleIDsCompletionBlock) {
|
||||
func mark(_ articleIDs: Set<String>, _ statusKey: ArticleStatus.Key, _ flag: Bool, _ completion: DatabaseCompletionBlock?) {
|
||||
queue.runInTransaction { databaseResult in
|
||||
switch databaseResult {
|
||||
case .success(let database):
|
||||
let newStatusIDs = self.statusesTable.markAndFetchNew(articleIDs, statusKey, flag, database)
|
||||
self.statusesTable.mark(articleIDs, statusKey, flag, database)
|
||||
DispatchQueue.main.async {
|
||||
completion(.success(newStatusIDs))
|
||||
completion?(nil)
|
||||
}
|
||||
case .failure(let databaseError):
|
||||
DispatchQueue.main.async {
|
||||
completion(.failure(databaseError))
|
||||
completion?(databaseError)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ final class StatusesTable: DatabaseTable {
|
||||
|
||||
// MARK: - Creating/Updating
|
||||
|
||||
func ensureStatusesForArticleIDs(_ articleIDs: Set<String>, _ read: Bool, _ database: FMDatabase) -> ([String: ArticleStatus], Set<String>) {
|
||||
func ensureStatusesForArticleIDs(_ articleIDs: Set<String>, _ read: Bool, _ database: FMDatabase) -> [String: ArticleStatus] {
|
||||
|
||||
#if DEBUG
|
||||
// Check for missing statuses — this asserts that all the passed-in articleIDs exist in the statuses table.
|
||||
@@ -44,7 +44,7 @@ final class StatusesTable: DatabaseTable {
|
||||
// Check cache.
|
||||
let articleIDsMissingCachedStatus = articleIDsWithNoCachedStatus(articleIDs)
|
||||
if articleIDsMissingCachedStatus.isEmpty {
|
||||
return (statusesDictionary(articleIDs), Set<String>())
|
||||
return statusesDictionary(articleIDs)
|
||||
}
|
||||
|
||||
// Check database.
|
||||
@@ -56,7 +56,7 @@ final class StatusesTable: DatabaseTable {
|
||||
self.createAndSaveStatusesForArticleIDs(articleIDsNeedingStatus, read, database)
|
||||
}
|
||||
|
||||
return (statusesDictionary(articleIDs), articleIDsNeedingStatus)
|
||||
return statusesDictionary(articleIDs)
|
||||
}
|
||||
|
||||
// MARK: - Marking
|
||||
@@ -85,11 +85,10 @@ final class StatusesTable: DatabaseTable {
|
||||
return updatedStatuses
|
||||
}
|
||||
|
||||
func markAndFetchNew(_ articleIDs: Set<String>, _ statusKey: ArticleStatus.Key, _ flag: Bool, _ database: FMDatabase) -> Set<String> {
|
||||
let (statusesDictionary, newStatusIDs) = ensureStatusesForArticleIDs(articleIDs, flag, database)
|
||||
func mark(_ articleIDs: Set<String>, _ statusKey: ArticleStatus.Key, _ flag: Bool, _ database: FMDatabase) {
|
||||
let statusesDictionary = ensureStatusesForArticleIDs(articleIDs, flag, database)
|
||||
let statuses = Set(statusesDictionary.values)
|
||||
mark(statuses, statusKey, flag, database)
|
||||
return newStatusIDs
|
||||
}
|
||||
|
||||
// MARK: - Fetching
|
||||
|
||||
Reference in New Issue
Block a user