Prefetch content and update share extension info after saving items

This commit is contained in:
Jackson Harper
2022-11-17 14:33:05 +08:00
committed by Hongbo Wu
parent 60a663e9bb
commit c523010427
2 changed files with 13 additions and 4 deletions

View File

@ -172,6 +172,15 @@ public class ShareExtensionViewModel: ObservableObject {
}
updateStatusOnMain(requestId: newRequestID, newStatus: .synced)
// Prefetch the newly saved content
if let itemID = newRequestID,
let currentViewer = services.dataService.currentViewer?.username,
(try? await services.dataService.loadArticleContentWithRetries(itemID: itemID, username: currentViewer)) != nil
{
updateStatusOnMain(requestId: requestId, newStatus: .saved, objectID: linkedItemObjectID)
}
return true
}
@ -184,6 +193,10 @@ public class ShareExtensionViewModel: ObservableObject {
if let objectID = objectID {
self.linkedItem = self.services.dataService.viewContext.object(with: objectID) as? LinkedItem
if let title = self.linkedItem?.title {
self.title = title
}
self.url = self.linkedItem?.pageURLString
}
}
}

View File

@ -77,10 +77,6 @@ struct LabelsMasonaryView: View {
}
private func item(for item: (label: LinkedItemLabel, selected: Bool)) -> some View {
if item.selected {
print(" -- SELECTED LABEL", item.label.name)
}
print("GETTING ITERATION", iteration)
let chip = TextChip(feedItemLabel: item.label, negated: false, checked: item.selected) { chip in
onLabelTap(item.label, chip)
}