Merge branch 'master' into extension-point
This commit is contained in:
commit
c414d22666
|
@ -233,7 +233,7 @@ private extension CloudKitArticlesZone {
|
|||
let encoder = JSONEncoder()
|
||||
var parsedAuthors = [String]()
|
||||
|
||||
if let authors = article.authors {
|
||||
if let authors = article.authors, !authors.isEmpty {
|
||||
for author in authors {
|
||||
let parsedAuthor = ParsedAuthor(name: author.name,
|
||||
url: author.url,
|
||||
|
@ -243,10 +243,9 @@ private extension CloudKitArticlesZone {
|
|||
parsedAuthors.append(encodedParsedAuthor)
|
||||
}
|
||||
}
|
||||
articleRecord[CloudKitArticle.Fields.parsedAuthors] = parsedAuthors
|
||||
}
|
||||
|
||||
articleRecord[CloudKitArticle.Fields.parsedAuthors] = parsedAuthors
|
||||
|
||||
records.append(articleRecord)
|
||||
return records
|
||||
}
|
||||
|
|
|
@ -474,6 +474,8 @@ extension CloudKitZone {
|
|||
/// Fetch all the changes in the CKZone since the last time we checked
|
||||
func fetchChangesInZone(completion: @escaping (Result<Void, Error>) -> Void) {
|
||||
|
||||
var savedChangeToken = changeToken
|
||||
|
||||
var changedRecords = [CKRecord]()
|
||||
var deletedRecordKeys = [CloudKitRecordKey]()
|
||||
|
||||
|
@ -482,12 +484,8 @@ extension CloudKitZone {
|
|||
let op = CKFetchRecordZoneChangesOperation(recordZoneIDs: [Self.zoneID], configurationsByRecordZoneID: [Self.zoneID: zoneConfig])
|
||||
op.fetchAllChanges = true
|
||||
|
||||
op.recordZoneChangeTokensUpdatedBlock = { [weak self] zoneID, token, _ in
|
||||
guard let self = self else { return }
|
||||
|
||||
DispatchQueue.main.async {
|
||||
self.changeToken = token
|
||||
}
|
||||
op.recordZoneChangeTokensUpdatedBlock = { zoneID, token, _ in
|
||||
savedChangeToken = token
|
||||
}
|
||||
|
||||
op.recordChangedBlock = { record in
|
||||
|
@ -499,20 +497,9 @@ extension CloudKitZone {
|
|||
deletedRecordKeys.append(recordKey)
|
||||
}
|
||||
|
||||
op.recordZoneFetchCompletionBlock = { [weak self] zoneID ,token, _, _, error in
|
||||
guard let self = self else { return }
|
||||
|
||||
switch CloudKitZoneResult.resolve(error) {
|
||||
case .success:
|
||||
DispatchQueue.main.async {
|
||||
self.changeToken = token
|
||||
}
|
||||
case .retry(let timeToWait):
|
||||
self.retryIfPossible(after: timeToWait) {
|
||||
self.fetchChangesInZone(completion: completion)
|
||||
}
|
||||
default:
|
||||
os_log(.error, log: self.log, "%@ zone fetch changes error: %@", zoneID.zoneName, error?.localizedDescription ?? "Unknown")
|
||||
op.recordZoneFetchCompletionBlock = { zoneID ,token, _, _, error in
|
||||
if case .success = CloudKitZoneResult.resolve(error) {
|
||||
savedChangeToken = token
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -522,7 +509,15 @@ extension CloudKitZone {
|
|||
switch CloudKitZoneResult.resolve(error) {
|
||||
case .success:
|
||||
DispatchQueue.main.async {
|
||||
self.delegate?.cloudKitDidModify(changed: changedRecords, deleted: deletedRecordKeys, completion: completion)
|
||||
self.delegate?.cloudKitDidModify(changed: changedRecords, deleted: deletedRecordKeys) { result in
|
||||
switch result {
|
||||
case .success:
|
||||
self.changeToken = savedChangeToken
|
||||
completion(.success(()))
|
||||
case .failure(let error):
|
||||
completion(.failure(error))
|
||||
}
|
||||
}
|
||||
}
|
||||
case .zoneNotFound:
|
||||
self.createZoneRecord() { result in
|
||||
|
|
|
@ -230,7 +230,7 @@ private extension ArticleRenderer {
|
|||
byline += name.htmlByAddingLink(url)
|
||||
}
|
||||
else if let name = author.name, let emailAddress = author.emailAddress {
|
||||
byline += "\(name) <\(emailAddress)≶"
|
||||
byline += "\(name) <\(emailAddress)>"
|
||||
}
|
||||
else if let name = author.name {
|
||||
byline += name
|
||||
|
|
Loading…
Reference in New Issue