set pdf state to success even if download has not completed

This commit is contained in:
Satindar Dhillon 2022-05-27 10:25:34 -07:00
parent 26a5b5dae1
commit c08c710601
2 changed files with 9 additions and 2 deletions

View file

@ -154,7 +154,7 @@ extension DataService {
return
}
if status == .succeeded {
if status == .succeeded || result.item.isPDF {
do {
try self?.persistArticleContent(
item: result.item,
@ -174,7 +174,7 @@ extension DataService {
let articleContent = ArticleContent(
htmlContent: result.htmlContent,
highlightsJSONString: result.highlights.asJSONString,
contentStatus: .make(from: result.contentStatus)
contentStatus: result.item.isPDF ? .succeeded : .make(from: result.contentStatus)
)
continuation.resume(returning: articleContent)

View file

@ -23,6 +23,13 @@ struct InternalLinkedItem {
let contentReader: String?
var labels: [InternalLinkedItemLabel]
var isPDF: Bool {
if let contentReader = contentReader {
return contentReader == "PDF"
}
return (pageURLString ?? "").hasSuffix("pdf")
}
func asManagedObject(inContext context: NSManagedObjectContext) -> LinkedItem {
let existingItem = LinkedItem.lookup(byID: id, inContext: context)
let linkedItem = existingItem ?? LinkedItem(entity: LinkedItem.entity(), insertInto: context)