Merge pull request #1495 from kielgillard/ios-candidate

Models the feed identifier of feedly articles as an optional…
This commit is contained in:
Maurice Parker 2019-12-30 14:55:30 -07:00 committed by GitHub
commit 8a85b18d09
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 5 deletions

View File

@ -17,10 +17,10 @@ struct FeedlyEntryParser {
return entry.id
}
var feedUrl: String {
var feedUrl: String? {
guard let id = entry.origin?.streamId else {
assertionFailure()
return ""
return nil
}
return id
}
@ -82,7 +82,11 @@ struct FeedlyEntryParser {
return attachments.isEmpty ? nil : Set(attachments)
}
var parsedItemRepresentation: ParsedItem {
var parsedItemRepresentation: ParsedItem? {
guard let feedUrl = feedUrl else {
return nil
}
return ParsedItem(syncServiceID: id,
uniqueID: id, // This value seems to get ignored or replaced.
feedURL: feedUrl,

View File

@ -10,6 +10,6 @@ import Foundation
struct FeedlyOrigin: Decodable {
var title: String?
var streamId: String
var streamId: String?
var htmlUrl: String
}

View File

@ -50,7 +50,17 @@ final class FeedlyGetStreamContentsOperation: FeedlyOperation, FeedlyEntryProvid
return entries
}
let parsed = Set(entries.map { FeedlyEntryParser(entry: $0).parsedItemRepresentation })
let parsed = Set(entries.compactMap {
FeedlyEntryParser(entry: $0).parsedItemRepresentation
})
if parsed.count != entries.count {
let entryIds = Set(entries.map { $0.id })
let parsedIds = Set(parsed.map { $0.uniqueID })
let difference = entryIds.subtracting(parsedIds)
os_log(.debug, log: log, "Dropping articles with ids: %{public}@.", difference)
}
storedParsedEntries = parsed
return parsed