mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
When opening with a request id check core data first for an item
This commit is contained in:
parent
b76b2ef4cb
commit
4ff8a9b83d
1 changed files with 11 additions and 0 deletions
|
|
@ -1,3 +1,4 @@
|
|||
import CoreData
|
||||
import Models
|
||||
import Services
|
||||
import SwiftUI
|
||||
|
|
@ -24,6 +25,16 @@ import Utils
|
|||
|
||||
guard let username = username else { return }
|
||||
|
||||
let fetchRequest: NSFetchRequest<Models.LinkedItem> = LinkedItem.fetchRequest()
|
||||
fetchRequest.predicate = NSPredicate(format: "id == %@", requestID)
|
||||
if let existingItem = try? dataService.viewContext.fetch(fetchRequest).first,
|
||||
existingItem.serverSyncStatus == ServerSyncStatus.isNSync.rawValue
|
||||
{
|
||||
print("USING EXISTING ITEM", existingItem.serverSyncStatus)
|
||||
item = existingItem
|
||||
return
|
||||
}
|
||||
|
||||
// If the page was locally created, make sure they are synced before we pull content
|
||||
await dataService.syncUnsyncedArticleContent(itemID: requestID)
|
||||
await fetchLinkedItem(dataService: dataService, requestID: requestID, username: username)
|
||||
|
|
|
|||
Loading…
Reference in a new issue