diff --git a/Account/Sources/Account/CloudKit/CloudKitAccountDelegate.swift b/Account/Sources/Account/CloudKit/CloudKitAccountDelegate.swift index c0f1a0bd8..67baad592 100644 --- a/Account/Sources/Account/CloudKit/CloudKitAccountDelegate.swift +++ b/Account/Sources/Account/CloudKit/CloudKitAccountDelegate.swift @@ -408,7 +408,7 @@ enum CloudKitAccountDelegateError: LocalizedError { SyncStatus(articleID: article.articleID, key: SyncStatus.Key(statusKey), flag: flag) } - try? await database.insertStatuses(syncStatuses) + try? await database.insertStatuses(Set(syncStatuses)) if let count = try? await self.database.selectPendingCount(), count > 100 { try await sendArticleStatus(for: account, showProgress: false) } @@ -671,7 +671,7 @@ private extension CloudKitAccountDelegate { return SyncStatus(articleID: article.articleID, key: statusKey, flag: flag) } - try? await database.insertStatuses(syncStatuses) + try? await database.insertStatuses(Set(syncStatuses)) } func sendArticleStatus(for account: Account, showProgress: Bool) async throws { diff --git a/Account/Sources/Account/CloudKit/CloudKitArticlesZoneDelegate.swift b/Account/Sources/Account/CloudKit/CloudKitArticlesZoneDelegate.swift index 57d2c24c2..8cba3aae9 100644 --- a/Account/Sources/Account/CloudKit/CloudKitArticlesZoneDelegate.swift +++ b/Account/Sources/Account/CloudKit/CloudKitArticlesZoneDelegate.swift @@ -124,7 +124,7 @@ private extension CloudKitArticlesZoneDelegate { } let syncStatuses = deletes.map { SyncStatus(articleID: $0.articleID, key: .deleted, flag: true) } - try? await self.database.insertStatuses(syncStatuses) + try? await self.database.insertStatuses(Set(syncStatuses)) } catch { errorOccurred = true diff --git a/Account/Sources/Account/Feedbin/FeedbinAccountDelegate.swift b/Account/Sources/Account/Feedbin/FeedbinAccountDelegate.swift index 7889048aa..ac35d9bd2 100644 --- a/Account/Sources/Account/Feedbin/FeedbinAccountDelegate.swift +++ b/Account/Sources/Account/Feedbin/FeedbinAccountDelegate.swift @@ -378,7 +378,7 @@ public enum FeedbinAccountDelegateError: String, Error { return SyncStatus(articleID: article.articleID, key: SyncStatus.Key(statusKey), flag: flag) } - try? await database.insertStatuses(syncStatuses) + try? await database.insertStatuses(Set(syncStatuses)) if let count = try? await database.selectPendingCount(), count > 100 { try? await sendArticleStatus(for: account) diff --git a/Account/Sources/Account/Feedly/FeedlyAccountDelegate.swift b/Account/Sources/Account/Feedly/FeedlyAccountDelegate.swift index 975373df7..0c55e8862 100644 --- a/Account/Sources/Account/Feedly/FeedlyAccountDelegate.swift +++ b/Account/Sources/Account/Feedly/FeedlyAccountDelegate.swift @@ -357,7 +357,7 @@ final class FeedlyAccountDelegate: AccountDelegate { return SyncStatus(articleID: article.articleID, key: SyncStatus.Key(statusKey), flag: flag) } - try? await syncDatabase.insertStatuses(syncStatuses) + try? await syncDatabase.insertStatuses(Set(syncStatuses)) if let count = try? await syncDatabase.selectPendingCount(), count > 100 { try? await sendArticleStatus(for: account) diff --git a/Account/Sources/Account/NewsBlur/NewsBlurAccountDelegate.swift b/Account/Sources/Account/NewsBlur/NewsBlurAccountDelegate.swift index 8fefaf976..0e98b637a 100644 --- a/Account/Sources/Account/NewsBlur/NewsBlurAccountDelegate.swift +++ b/Account/Sources/Account/NewsBlur/NewsBlurAccountDelegate.swift @@ -411,7 +411,7 @@ final class NewsBlurAccountDelegate: AccountDelegate { let syncStatuses = articles.map { article in return SyncStatus(articleID: article.articleID, key: SyncStatus.Key(statusKey), flag: flag) } - try? await syncDatabase.insertStatuses(syncStatuses) + try? await syncDatabase.insertStatuses(Set(syncStatuses)) if let count = try? await syncDatabase.selectPendingCount(), count > 100 { try await sendArticleStatus(for: account) diff --git a/Account/Sources/Account/ReaderAPI/ReaderAPIAccountDelegate.swift b/Account/Sources/Account/ReaderAPI/ReaderAPIAccountDelegate.swift index d3c8965e9..fbde32048 100644 --- a/Account/Sources/Account/ReaderAPI/ReaderAPIAccountDelegate.swift +++ b/Account/Sources/Account/ReaderAPI/ReaderAPIAccountDelegate.swift @@ -443,7 +443,7 @@ final class ReaderAPIAccountDelegate: AccountDelegate { return SyncStatus(articleID: article.articleID, key: SyncStatus.Key(statusKey), flag: flag) } - try await self.database.insertStatuses(syncStatuses) + try await self.database.insertStatuses(Set(syncStatuses)) if let count = try await self.database.selectPendingCount(), count > 100 { try await sendArticleStatus(for: account) diff --git a/SyncDatabase/Sources/SyncDatabase/SyncDatabase.swift b/SyncDatabase/Sources/SyncDatabase/SyncDatabase.swift index aa5579cf2..72ebdc7c6 100644 --- a/SyncDatabase/Sources/SyncDatabase/SyncDatabase.swift +++ b/SyncDatabase/Sources/SyncDatabase/SyncDatabase.swift @@ -28,7 +28,7 @@ public actor SyncDatabase { // MARK: - API - public func insertStatuses(_ statuses: [SyncStatus]) throws { + public func insertStatuses(_ statuses: Set) throws { guard let database else { throw DatabaseError.suspended diff --git a/SyncDatabase/Sources/SyncDatabase/SyncStatusTable.swift b/SyncDatabase/Sources/SyncDatabase/SyncStatusTable.swift index 62349a0c5..381d72c73 100644 --- a/SyncDatabase/Sources/SyncDatabase/SyncStatusTable.swift +++ b/SyncDatabase/Sources/SyncDatabase/SyncStatusTable.swift @@ -88,7 +88,7 @@ struct SyncStatusTable { database.executeUpdateInTransaction(deleteSQL, withArgumentsIn: parameters) } - func insertStatuses(_ statuses: [SyncStatus], database: FMDatabase) { + func insertStatuses(_ statuses: Set, database: FMDatabase) { database.beginTransaction()