From 491df567a6f557c67fa820da129fb0ce30672872 Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Tue, 1 Sep 2026 11:08:51 -0700 Subject: [PATCH] Fix potential Feedbin sync bug by storing conditional GET info after, not before, updating model. --- .../Sources/Account/Feedbin/FeedbinAPICaller.swift | 10 ++++------ .../Account/Feedbin/FeedbinAccountDelegate.swift | 6 ++++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Modules/Account/Sources/Account/Feedbin/FeedbinAPICaller.swift b/Modules/Account/Sources/Account/Feedbin/FeedbinAPICaller.swift index 9707a80cf..3a49a7592 100644 --- a/Modules/Account/Sources/Account/Feedbin/FeedbinAPICaller.swift +++ b/Modules/Account/Sources/Account/Feedbin/FeedbinAPICaller.swift @@ -365,7 +365,7 @@ enum CreateSubscriptionResult { return (entries, pagingInfo.nextPage) } - func retrieveUnreadEntries() async throws -> [Int]? { + func retrieveUnreadEntries() async throws -> (unreadArticleIDs: [Int]?, response: HTTPURLResponse) { if suspended { throw WebserviceError.suspended } @@ -375,8 +375,7 @@ enum CreateSubscriptionResult { let request = URLRequest(url: callURL, credentials: credentials, conditionalGet: conditionalGet) let (response, unreadEntries) = try await session.send(request: request, resultType: [Int].self) - storeConditionalGet(key: ConditionalGetKeys.unreadEntries, response: response) - return unreadEntries + return (unreadEntries, response) } func createUnreadEntries(entries: [Int]) async throws { @@ -403,7 +402,7 @@ enum CreateSubscriptionResult { try await session.send(request: request, method: HTTPMethod.delete, payload: payload) } - func retrieveStarredEntries() async throws -> [Int]? { + func retrieveStarredEntries() async throws -> (starredArticleIDs: [Int]?, response: HTTPURLResponse) { if suspended { throw WebserviceError.suspended } @@ -413,8 +412,7 @@ enum CreateSubscriptionResult { let request = URLRequest(url: callURL, credentials: credentials, conditionalGet: conditionalGet) let (response, starredEntries) = try await session.send(request: request, resultType: [Int].self) - storeConditionalGet(key: ConditionalGetKeys.starredEntries, response: response) - return starredEntries + return (starredEntries, response) } func createStarredEntries(entries: [Int]) async throws { diff --git a/Modules/Account/Sources/Account/Feedbin/FeedbinAccountDelegate.swift b/Modules/Account/Sources/Account/Feedbin/FeedbinAccountDelegate.swift index 8e44feace..3fee2a816 100644 --- a/Modules/Account/Sources/Account/Feedbin/FeedbinAccountDelegate.swift +++ b/Modules/Account/Sources/Account/Feedbin/FeedbinAccountDelegate.swift @@ -157,16 +157,18 @@ public enum FeedbinAccountDelegateError: String, Error, Sendable { var refreshError: Error? do { - let articleIDs = try await caller.retrieveUnreadEntries() + let (articleIDs, response) = try await caller.retrieveUnreadEntries() changedCount += await self.syncArticleReadState(account: account, articleIDs: articleIDs) + caller.storeConditionalGet(key: FeedbinAPICaller.ConditionalGetKeys.unreadEntries, response: response) } catch { refreshError = error Self.logger.error("Feedbin: Retrieving unread entries failed: \(error.localizedDescription)") } do { - let articleIDs = try await caller.retrieveStarredEntries() + let (articleIDs, response) = try await caller.retrieveStarredEntries() changedCount += await self.syncArticleStarredState(account: account, articleIDs: articleIDs) + caller.storeConditionalGet(key: FeedbinAPICaller.ConditionalGetKeys.starredEntries, response: response) } catch { refreshError = error Self.logger.error("Feedbin: Retrieving starred entries failed: \(error.localizedDescription)")