This commit is contained in:
Brent Simmons committed 2026-08-03 14:10:59 -07:00
commit 7067b8ce7b
6 files changed
+50 -13

No files matched your search

@@ -137,7 +137,9 @@ private extension AddFeedWindowController {
}
func selectedContainer() -> Container? {
guard folderPopupButton.selectedItem?.isEnabled ?? false else { return nil }
return folderPopupButton.selectedItem?.representedObject as? Container
guard let selectedItem = folderPopupButton.selectedItem, selectedItem.isEnabled else {
return nil
}
return selectedItem.representedObject as? Container
}
}
@@ -449,6 +449,11 @@ public enum FeedbinAccountDelegateError: String, Error, Sendable {
func accountDidInitialize() {
credentials = try? account?.retrieveCredentials(type: .basic)
// A send in progress when the app was killed left its statuses selected. Clear them so
// they get sent, instead of waiting for the next selectForProcessing to pick them up.
// <https://github.com/Ranchero-Software/NetNewsWire/issues/4280>
syncDatabase.resetAllSelectedForProcessing()
}
func accountWillBeDeleted() {
@@ -779,6 +779,11 @@ import Secrets
}
Self.logger.debug("FeedlyAccountDelegate: accountDidInitialize")
credentials = try? account.retrieveCredentials(type: .oauthAccessToken)
// A send in progress when the app was killed left its statuses selected. Clear them so
// they get sent, instead of waiting for the next selectForProcessing to pick them up.
// <https://github.com/Ranchero-Software/NetNewsWire/issues/4280>
syncDatabase.resetAllSelectedForProcessing()
}
func accountWillBeDeleted() {
@@ -511,6 +511,11 @@ import Secrets
func accountDidInitialize() {
credentials = try? account?.retrieveCredentials(type: .newsBlurSessionID)
// A send in progress when the app was killed left its statuses selected. Clear them so
// they get sent, instead of waiting for the next selectForProcessing to pick them up.
// <https://github.com/Ranchero-Software/NetNewsWire/issues/4280>
syncDatabase.resetAllSelectedForProcessing()
}
func accountWillBeDeleted() {
@@ -679,6 +679,11 @@ final class ReaderAPIAccountDelegate: AccountDelegate {
return
}
retrieveCredentialsIfNeeded(account)
// A send in progress when the app was killed left its statuses selected. Clear them so
// they get sent, instead of waiting for the next selectForProcessing to pick them up.
// <https://github.com/Ranchero-Software/NetNewsWire/issues/4280>
syncDatabase.resetAllSelectedForProcessing()
}
func accountWillBeDeleted() {
@@ -14,17 +14,14 @@ import RSDatabaseObjC
struct SyncStatusTable {
static let name = "syncStatus"
// Selects first, then marks just the rows being returned. Marking every row would flag rows
// past the limit as in-flight, and `deleteSelectedForProcessing` with a nil key would then
// delete a queued status that was never sent.
static func selectForProcessing(limit: Int?, database: FMDatabase) -> Set<SyncStatus>? {
database.beginTransaction()
let updateSQL = "update \(name) set selected = true"
guard database.executeUpdate(updateSQL, withArgumentsIn: nil) else {
database.rollback()
return nil
}
let selectSQL = {
var sql = "select * from \(name) where selected == true"
var sql = "select * from \(name)"
if let limit {
sql = "\(sql) limit \(limit)"
}
@@ -37,10 +34,28 @@ struct SyncStatusTable {
}
let statuses = resultSet.mapToSet(statusWithRow)
guard !statuses.isEmpty else {
database.commit()
return statuses
}
// An articleID can have both a read row and a starred row, so match on the pair.
var parameters = [AnyObject]()
let conditions = statuses.map { status -> String in
parameters.append(status.articleID as AnyObject)
parameters.append(status.key.rawValue as AnyObject)
return "(articleID = ? and key = ?)"
}
let updateSQL = "update \(name) set selected = true where \(conditions.joined(separator: " or "))"
guard database.executeUpdate(updateSQL, withArgumentsIn: parameters) else {
database.rollback()
return nil
}
database.commit()
return statuses
return Set(statuses.map { SyncStatus(articleID: $0.articleID, key: $0.key, flag: $0.flag, selected: true) })
}
static func selectPendingCount(database: FMDatabase) -> Int? {
@@ -124,10 +139,10 @@ private extension SyncStatusTable {
return SyncStatus(articleID: articleID, key: key, flag: flag, selected: selected)
}
// Includes rows that are selected — a send in flight hasn’t been confirmed by the server yet,
// and skipping those let a concurrent refresh revert the change the send was carrying.
// <https://github.com/Ranchero-Software/NetNewsWire/issues/4280>
static func selectPendingArticleIDs(_ statusKey: ArticleStatus.Key, database: FMDatabase) -> Set<String>? {
// Rows selected for an in-flight send are still pending — they’re only deleted
// once the send is confirmed. Excluding them let a concurrent send make every
// pending edit invisible to status ingestion, which then reverted the edits.
let sql = "select articleID from \(name) where key = \"\(statusKey.rawValue)\";"
guard let resultSet = database.executeQuery(sql, withArgumentsIn: nil) else {
return nil