Merge branch 'mac-release'

This commit is contained in:
Maurice Parker 2019-08-30 11:28:16 -05:00
commit ea1f21797c
6 changed files with 93 additions and 96 deletions

View File

@ -564,16 +564,16 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
database.fetchStarredAndUnreadCount(for: flattenedFeeds().feedIDs(), callback: callback)
}
public func fetchUnreadArticleIDs(_ callback: @escaping (Set<String>) -> Void) {
database.fetchUnreadArticleIDs(callback)
public func fetchUnreadArticleIDs() -> Set<String> {
return database.fetchUnreadArticleIDs()
}
public func fetchStarredArticleIDs(_ callback: @escaping (Set<String>) -> Void) {
database.fetchStarredArticleIDs(callback)
public func fetchStarredArticleIDs() -> Set<String> {
return database.fetchStarredArticleIDs()
}
public func fetchArticleIDsForStatusesWithoutArticles(_ callback: @escaping (Set<String>) -> Void) {
database.fetchArticleIDsForStatusesWithoutArticles(callback)
public func fetchArticleIDsForStatusesWithoutArticles() -> Set<String> {
return database.fetchArticleIDsForStatusesWithoutArticles()
}
public func opmlDocument() -> String {
@ -657,9 +657,9 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
return updatedArticles
}
func ensureStatuses(_ articleIDs: Set<String>, _ statusKey: ArticleStatus.Key, _ flag: Bool) {
func ensureStatuses(_ articleIDs: Set<String>, _ defaultRead: Bool, _ statusKey: ArticleStatus.Key, _ flag: Bool) {
if !articleIDs.isEmpty {
database.ensureStatuses(articleIDs, statusKey, flag)
database.ensureStatuses(articleIDs, defaultRead, statusKey, flag)
}
}

View File

@ -83,9 +83,9 @@ final class FeedbinAccountDelegate: AccountDelegate {
switch result {
case .success():
self.refreshArticles(account) {
self.sendArticleStatus(for: account) {
self.refreshArticleStatus(for: account) {
self.refreshArticles(account) {
self.refreshMissingArticles(account) {
self.refreshProgress.clear()
DispatchQueue.main.async {
@ -948,8 +948,8 @@ private extension FeedbinAccountDelegate {
case .success(let (entries, page)):
self.processEntries(account: account, entries: entries) {
self.refreshArticles(account, page: page) {
self.refreshArticleStatus(for: account) {
self.refreshArticles(account, page: page) {
self.refreshProgress.completeTask()
self.refreshMissingArticles(account) {
self.refreshProgress.completeTask()
@ -1005,9 +1005,10 @@ private extension FeedbinAccountDelegate {
os_log(.debug, log: log, "Refreshing missing articles...")
let group = DispatchGroup()
account.fetchArticleIDsForStatusesWithoutArticles { (fetchedArticleIDs) in
let fetchedArticleIDs = account.fetchArticleIDsForStatusesWithoutArticles()
let articleIDs = Array(fetchedArticleIDs)
let chunkedArticleIDs = articleIDs.chunked(into: 100)
for chunk in chunkedArticleIDs {
group.enter()
self.caller.retrieveEntries(articleIDs: chunk) { result in
@ -1025,7 +1026,6 @@ private extension FeedbinAccountDelegate {
}
}
}
}
group.notify(queue: DispatchQueue.main) {
self.refreshProgress.completeTask()
@ -1110,29 +1110,28 @@ private extension FeedbinAccountDelegate {
}
let feedbinUnreadArticleIDs = Set(articleIDs.map { String($0) } )
account.fetchUnreadArticleIDs { (currentUnreadArticleIDs) in
let currentUnreadArticleIDs = account.fetchUnreadArticleIDs()
// Mark articles as unread
let deltaUnreadArticleIDs = feedbinUnreadArticleIDs.subtracting(currentUnreadArticleIDs)
account.fetchArticlesAsync(.articleIDs(deltaUnreadArticleIDs)) { (markUnreadArticles) in
let markUnreadArticles = account.fetchArticles(.articleIDs(deltaUnreadArticleIDs))
account.update(markUnreadArticles, statusKey: .read, flag: false)
// Save any unread statuses for articles we haven't yet received
let markUnreadArticleIDs = Set(markUnreadArticles.map { $0.articleID })
let missingUnreadArticleIDs = deltaUnreadArticleIDs.subtracting(markUnreadArticleIDs)
account.ensureStatuses(missingUnreadArticleIDs, .read, false)
}
account.ensureStatuses(missingUnreadArticleIDs, true, .read, false)
// Mark articles as read
let deltaReadArticleIDs = currentUnreadArticleIDs.subtracting(feedbinUnreadArticleIDs)
account.fetchArticlesAsync(.articleIDs(deltaReadArticleIDs)) { (markReadArticles) in
let markReadArticles = account.fetchArticles(.articleIDs(deltaReadArticleIDs))
account.update(markReadArticles, statusKey: .read, flag: true)
// Save any read statuses for articles we haven't yet received
let markReadArticleIDs = Set(markReadArticles.map { $0.articleID })
let missingReadArticleIDs = deltaReadArticleIDs.subtracting(markReadArticleIDs)
account.ensureStatuses(missingReadArticleIDs, .read, true)
}
}
account.ensureStatuses(missingReadArticleIDs, true, .read, true)
}
func syncArticleStarredState(account: Account, articleIDs: [Int]?) {
@ -1141,29 +1140,27 @@ private extension FeedbinAccountDelegate {
}
let feedbinStarredArticleIDs = Set(articleIDs.map { String($0) } )
account.fetchStarredArticleIDs { (currentStarredArticleIDs) in
let currentStarredArticleIDs = account.fetchStarredArticleIDs()
// Mark articles as starred
let deltaStarredArticleIDs = feedbinStarredArticleIDs.subtracting(currentStarredArticleIDs)
account.fetchArticlesAsync(.articleIDs(deltaStarredArticleIDs)) { (markStarredArticles) in
let markStarredArticles = account.fetchArticles(.articleIDs(deltaStarredArticleIDs))
account.update(markStarredArticles, statusKey: .starred, flag: true)
// Save any starred statuses for articles we haven't yet received
let markStarredArticleIDs = Set(markStarredArticles.map { $0.articleID })
let missingStarredArticleIDs = deltaStarredArticleIDs.subtracting(markStarredArticleIDs)
account.ensureStatuses(missingStarredArticleIDs, .starred, true)
}
account.ensureStatuses(missingStarredArticleIDs, true, .starred, true)
// Mark articles as unstarred
let deltaUnstarredArticleIDs = currentStarredArticleIDs.subtracting(feedbinStarredArticleIDs)
account.fetchArticlesAsync(.articleIDs(deltaUnstarredArticleIDs)) { (markUnstarredArticles) in
let markUnstarredArticles = account.fetchArticles(.articleIDs(deltaUnstarredArticleIDs))
account.update(markUnstarredArticles, statusKey: .starred, flag: false)
// Save any unstarred statuses for articles we haven't yet received
let markUnstarredArticleIDs = Set(markUnstarredArticles.map { $0.articleID })
let missingUnstarredArticleIDs = deltaUnstarredArticleIDs.subtracting(markUnstarredArticleIDs)
account.ensureStatuses(missingUnstarredArticleIDs, .starred, false)
}
}
account.ensureStatuses(missingUnstarredArticleIDs, true, .starred, false)
}
func deleteTagging(for account: Account, with feed: Feed, from container: Container?, completion: @escaping (Result<Void, Error>) -> Void) {

View File

@ -122,22 +122,22 @@ public final class ArticlesDatabase {
return articlesTable.update(feedID, parsedItems, defaultRead, completion)
}
public func ensureStatuses(_ articleIDs: Set<String>, _ statusKey: ArticleStatus.Key, _ flag: Bool) {
articlesTable.ensureStatuses(articleIDs, statusKey, flag)
public func ensureStatuses(_ articleIDs: Set<String>, _ defaultRead: Bool, _ statusKey: ArticleStatus.Key, _ flag: Bool) {
articlesTable.ensureStatuses(articleIDs, defaultRead, statusKey, flag)
}
// MARK: - Status
public func fetchUnreadArticleIDs(_ callback: @escaping (Set<String>) -> Void) {
articlesTable.fetchUnreadArticleIDs(callback)
public func fetchUnreadArticleIDs() -> Set<String> {
return articlesTable.fetchUnreadArticleIDs()
}
public func fetchStarredArticleIDs(_ callback: @escaping (Set<String>) -> Void) {
articlesTable.fetchStarredArticleIDs(callback)
public func fetchStarredArticleIDs() -> Set<String> {
return articlesTable.fetchStarredArticleIDs()
}
public func fetchArticleIDsForStatusesWithoutArticles(_ callback: @escaping (Set<String>) -> Void) {
articlesTable.fetchArticleIDsForStatusesWithoutArticles(callback)
public func fetchArticleIDsForStatusesWithoutArticles() -> Set<String> {
return articlesTable.fetchArticleIDsForStatusesWithoutArticles()
}
public func mark(_ articles: Set<Article>, statusKey: ArticleStatus.Key, flag: Bool) -> Set<ArticleStatus>? {

View File

@ -267,9 +267,9 @@ final class ArticlesTable: DatabaseTable {
}
}
func ensureStatuses(_ articleIDs: Set<String>, _ statusKey: ArticleStatus.Key, _ flag: Bool) {
func ensureStatuses(_ articleIDs: Set<String>, _ defaultRead: Bool, _ statusKey: ArticleStatus.Key, _ flag: Bool) {
self.queue.update { (database) in
let statusesDictionary = self.statusesTable.ensureStatusesForArticleIDs(articleIDs, false, database)
let statusesDictionary = self.statusesTable.ensureStatusesForArticleIDs(articleIDs, defaultRead, database)
let statuses = Set(statusesDictionary.values)
self.statusesTable.mark(statuses, statusKey, flag, database)
}
@ -371,16 +371,16 @@ final class ArticlesTable: DatabaseTable {
// MARK: - Statuses
func fetchUnreadArticleIDs(_ callback: @escaping (Set<String>) -> Void) {
statusesTable.fetchUnreadArticleIDs(callback)
func fetchUnreadArticleIDs() -> Set<String>{
return statusesTable.fetchUnreadArticleIDs()
}
func fetchStarredArticleIDs(_ callback: @escaping (Set<String>) -> Void) {
statusesTable.fetchStarredArticleIDs(callback)
func fetchStarredArticleIDs() -> Set<String> {
return statusesTable.fetchStarredArticleIDs()
}
func fetchArticleIDsForStatusesWithoutArticles(_ callback: @escaping (Set<String>) -> Void) {
statusesTable.fetchArticleIDsForStatusesWithoutArticles(callback)
func fetchArticleIDsForStatusesWithoutArticles() -> Set<String> {
return statusesTable.fetchArticleIDsForStatusesWithoutArticles()
}
func mark(_ articles: Set<Article>, _ statusKey: ArticleStatus.Key, _ flag: Bool) -> Set<ArticleStatus>? {

View File

@ -74,27 +74,27 @@ final class StatusesTable: DatabaseTable {
// MARK: - Fetching
func fetchUnreadArticleIDs(_ callback: @escaping (Set<String>) -> Void) {
fetchArticleIDs("select articleID from statuses where read=0 and userDeleted=0;", callback)
func fetchUnreadArticleIDs() -> Set<String> {
return fetchArticleIDs("select articleID from statuses where read=0 and userDeleted=0;")
}
func fetchStarredArticleIDs(_ callback: @escaping (Set<String>) -> Void) {
fetchArticleIDs("select articleID from statuses where starred=1 and userDeleted=0;", callback)
func fetchStarredArticleIDs() -> Set<String> {
return fetchArticleIDs("select articleID from statuses where starred=1 and userDeleted=0;")
}
func fetchArticleIDsForStatusesWithoutArticles(_ callback: @escaping (Set<String>) -> Void) {
fetchArticleIDs("select articleID from statuses s where (read=0 or starred=1) and userDeleted=0 and not exists (select 1 from articles a where a.articleID = s.articleID);", callback)
func fetchArticleIDsForStatusesWithoutArticles() -> Set<String> {
return fetchArticleIDs("select articleID from statuses s where (read=0 or starred=1) and userDeleted=0 and not exists (select 1 from articles a where a.articleID = s.articleID);")
}
func fetchArticleIDs(_ sql: String, _ callback: @escaping (Set<String>) -> Void) {
queue.fetch { (database) in
func fetchArticleIDs(_ sql: String) -> Set<String> {
var articleIDs = Set<String>()
queue.fetchSync { (database) in
guard let resultSet = database.executeQuery(sql, withArgumentsIn: nil) else {
callback(Set<String>())
return
}
let statuses = resultSet.mapToSet(self.articleIDWithRow)
callback(statuses)
articleIDs = resultSet.mapToSet(self.articleIDWithRow)
}
return articleIDs
}
func articleIDWithRow(_ row: FMResultSet) -> String? {

View File

@ -17,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>5.0</string>
<string>5.0.1a</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
@ -33,7 +33,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>2609</string>
<string>2610</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.news</string>
<key>LSMinimumSystemVersion</key>
@ -44,7 +44,7 @@
<true/>
</dict>
<key>NSAppleEventsUsageDescription</key>
<string>NetNewsWire communicates with other apps on your Mac when you choose to share a news item.</string>
<string>NetNewsWire communicates with other apps on your Mac when you choose to share an article.</string>
<key>NSAppleScriptEnabled</key>
<true/>
<key>NSHumanReadableCopyright</key>