Make insertStatuses take a Set.
This commit is contained in:
parent
d58821a7ad
commit
a474a8fc18
@ -408,7 +408,7 @@ enum CloudKitAccountDelegateError: LocalizedError {
|
|||||||
SyncStatus(articleID: article.articleID, key: SyncStatus.Key(statusKey), flag: flag)
|
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 {
|
if let count = try? await self.database.selectPendingCount(), count > 100 {
|
||||||
try await sendArticleStatus(for: account, showProgress: false)
|
try await sendArticleStatus(for: account, showProgress: false)
|
||||||
}
|
}
|
||||||
@ -671,7 +671,7 @@ private extension CloudKitAccountDelegate {
|
|||||||
return SyncStatus(articleID: article.articleID, key: statusKey, flag: flag)
|
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 {
|
func sendArticleStatus(for account: Account, showProgress: Bool) async throws {
|
||||||
|
@ -124,7 +124,7 @@ private extension CloudKitArticlesZoneDelegate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let syncStatuses = deletes.map { SyncStatus(articleID: $0.articleID, key: .deleted, flag: true) }
|
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 {
|
} catch {
|
||||||
errorOccurred = true
|
errorOccurred = true
|
||||||
|
@ -378,7 +378,7 @@ public enum FeedbinAccountDelegateError: String, Error {
|
|||||||
return SyncStatus(articleID: article.articleID, key: SyncStatus.Key(statusKey), flag: flag)
|
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 {
|
if let count = try? await database.selectPendingCount(), count > 100 {
|
||||||
try? await sendArticleStatus(for: account)
|
try? await sendArticleStatus(for: account)
|
||||||
|
@ -357,7 +357,7 @@ final class FeedlyAccountDelegate: AccountDelegate {
|
|||||||
return SyncStatus(articleID: article.articleID, key: SyncStatus.Key(statusKey), flag: flag)
|
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 {
|
if let count = try? await syncDatabase.selectPendingCount(), count > 100 {
|
||||||
try? await sendArticleStatus(for: account)
|
try? await sendArticleStatus(for: account)
|
||||||
|
@ -411,7 +411,7 @@ final class NewsBlurAccountDelegate: AccountDelegate {
|
|||||||
let syncStatuses = articles.map { article in
|
let syncStatuses = articles.map { article in
|
||||||
return SyncStatus(articleID: article.articleID, key: SyncStatus.Key(statusKey), flag: flag)
|
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 {
|
if let count = try? await syncDatabase.selectPendingCount(), count > 100 {
|
||||||
try await sendArticleStatus(for: account)
|
try await sendArticleStatus(for: account)
|
||||||
|
@ -443,7 +443,7 @@ final class ReaderAPIAccountDelegate: AccountDelegate {
|
|||||||
return SyncStatus(articleID: article.articleID, key: SyncStatus.Key(statusKey), flag: flag)
|
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 {
|
if let count = try await self.database.selectPendingCount(), count > 100 {
|
||||||
try await sendArticleStatus(for: account)
|
try await sendArticleStatus(for: account)
|
||||||
|
@ -28,7 +28,7 @@ public actor SyncDatabase {
|
|||||||
|
|
||||||
// MARK: - API
|
// MARK: - API
|
||||||
|
|
||||||
public func insertStatuses(_ statuses: [SyncStatus]) throws {
|
public func insertStatuses(_ statuses: Set<SyncStatus>) throws {
|
||||||
|
|
||||||
guard let database else {
|
guard let database else {
|
||||||
throw DatabaseError.suspended
|
throw DatabaseError.suspended
|
||||||
|
@ -88,7 +88,7 @@ struct SyncStatusTable {
|
|||||||
database.executeUpdateInTransaction(deleteSQL, withArgumentsIn: parameters)
|
database.executeUpdateInTransaction(deleteSQL, withArgumentsIn: parameters)
|
||||||
}
|
}
|
||||||
|
|
||||||
func insertStatuses(_ statuses: [SyncStatus], database: FMDatabase) {
|
func insertStatuses(_ statuses: Set<SyncStatus>, database: FMDatabase) {
|
||||||
|
|
||||||
database.beginTransaction()
|
database.beginTransaction()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user