Fix a few concurrency warnings.
This commit is contained in:
parent
51b78ddd70
commit
325f8061de
@ -995,7 +995,8 @@ public enum FetchType {
|
|||||||
// MARK: - AccountMetadataDelegate
|
// MARK: - AccountMetadataDelegate
|
||||||
|
|
||||||
extension Account: AccountMetadataDelegate {
|
extension Account: AccountMetadataDelegate {
|
||||||
func valueDidChange(_ accountMetadata: AccountMetadata, key: AccountMetadata.CodingKeys) {
|
|
||||||
|
nonisolated func valueDidChange(_ accountMetadata: AccountMetadata, key: AccountMetadata.CodingKeys) {
|
||||||
Task { @MainActor in
|
Task { @MainActor in
|
||||||
metadataFile.markAsDirty()
|
metadataFile.markAsDirty()
|
||||||
}
|
}
|
||||||
@ -1006,11 +1007,13 @@ extension Account: AccountMetadataDelegate {
|
|||||||
|
|
||||||
extension Account: FeedMetadataDelegate {
|
extension Account: FeedMetadataDelegate {
|
||||||
|
|
||||||
func valueDidChange(_ feedMetadata: FeedMetadata, key: FeedMetadata.CodingKeys) {
|
nonisolated func valueDidChange(_ feedMetadata: FeedMetadata, key: FeedMetadata.CodingKeys) {
|
||||||
|
|
||||||
|
let feedID = feedMetadata.feedID
|
||||||
|
|
||||||
Task { @MainActor in
|
Task { @MainActor in
|
||||||
feedMetadataFile.markAsDirty()
|
feedMetadataFile.markAsDirty()
|
||||||
guard let feed = existingFeed(withFeedID: feedMetadata.feedID) else {
|
guard let feed = existingFeed(withFeedID: feedID) else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
feed.postFeedSettingDidChangeNotification(key)
|
feed.postFeedSettingDidChangeNotification(key)
|
||||||
|
@ -57,7 +57,7 @@ final class CloudKitArticlesZoneDelegate: CloudKitZoneDelegate {
|
|||||||
|
|
||||||
private extension CloudKitArticlesZoneDelegate {
|
private extension CloudKitArticlesZoneDelegate {
|
||||||
|
|
||||||
func delete(recordKeys: [CloudKitRecordKey], pendingStarredStatusArticleIDs: Set<String>) async {
|
@MainActor func delete(recordKeys: [CloudKitRecordKey], pendingStarredStatusArticleIDs: Set<String>) async {
|
||||||
|
|
||||||
let receivedRecordIDs = recordKeys.filter({ $0.recordType == CloudKitArticlesZone.CloudKitArticleStatus.recordType }).map({ $0.recordID })
|
let receivedRecordIDs = recordKeys.filter({ $0.recordType == CloudKitArticlesZone.CloudKitArticleStatus.recordType }).map({ $0.recordID })
|
||||||
let receivedArticleIDs = Set(receivedRecordIDs.map({ stripPrefix($0.externalID) }))
|
let receivedArticleIDs = Set(receivedRecordIDs.map({ stripPrefix($0.externalID) }))
|
||||||
|
@ -445,14 +445,40 @@ private extension FeedbinAccountDelegate {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private func delay(seconds: Double) async {
|
||||||
|
|
||||||
|
await withCheckedContinuation { continuation in
|
||||||
|
self.performBlockAfter(seconds: seconds) {
|
||||||
|
continuation.resume()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
nonisolated private func performBlockAfter(seconds: Double, block: @escaping @Sendable @MainActor () -> ()) {
|
||||||
|
|
||||||
|
let delayTime = DispatchTime.now() + seconds
|
||||||
|
DispatchQueue.main.asyncAfter(deadline: delayTime) {
|
||||||
|
Task { @MainActor in
|
||||||
|
block()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func checkImportResult(opmlImportResultID: Int, completion: @escaping @Sendable (Result<Void, Error>) -> Void) {
|
func checkImportResult(opmlImportResultID: Int, completion: @escaping @Sendable (Result<Void, Error>) -> Void) {
|
||||||
|
|
||||||
DispatchQueue.main.async {
|
|
||||||
|
|
||||||
Timer.scheduledTimer(withTimeInterval: 15, repeats: true) { timer in
|
|
||||||
|
|
||||||
Task { @MainActor in
|
Task { @MainActor in
|
||||||
|
|
||||||
|
var retry = 0
|
||||||
|
let maxRetries = 6 // a guess at a good number
|
||||||
|
|
||||||
|
@MainActor func checkResult() async {
|
||||||
|
|
||||||
|
if retry >= maxRetries {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
retry = retry + 1
|
||||||
|
|
||||||
|
await delay(seconds: 15)
|
||||||
os_log(.debug, log: self.log, "Checking status of OPML import...")
|
os_log(.debug, log: self.log, "Checking status of OPML import...")
|
||||||
|
|
||||||
do {
|
do {
|
||||||
@ -460,17 +486,18 @@ private extension FeedbinAccountDelegate {
|
|||||||
|
|
||||||
if let importResult, importResult.complete {
|
if let importResult, importResult.complete {
|
||||||
os_log(.debug, log: self.log, "Checking status of OPML import successfully completed.")
|
os_log(.debug, log: self.log, "Checking status of OPML import successfully completed.")
|
||||||
timer.invalidate()
|
|
||||||
completion(.success(()))
|
completion(.success(()))
|
||||||
|
} else {
|
||||||
|
await checkResult()
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch {
|
} catch {
|
||||||
os_log(.debug, log: self.log, "Import OPML check failed.")
|
os_log(.debug, log: self.log, "Import OPML check failed.")
|
||||||
timer.invalidate()
|
|
||||||
completion(.failure(error))
|
completion(.failure(error))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
await checkResult()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user