rename article content models to avoid clashing

This commit is contained in:
Satindar Dhillon 2022-04-20 15:19:09 -07:00
parent 6968e06da5
commit 6658d1d69b
4 changed files with 9 additions and 9 deletions

View file

@ -11,7 +11,7 @@ struct SafariWebLink: Identifiable {
final class WebReaderViewModel: ObservableObject {
@Published var isLoading = false
@Published var articleContent: ArticleContentDep?
@Published var articleContent: ArticleContent?
var slug: String?
var subscriptions = Set<AnyCancellable>()

View file

@ -1,6 +1,6 @@
import Foundation
public struct ArticleContentDep {
public struct ArticleContent {
public let htmlContent: String
public let highlightsJSONString: String

View file

@ -76,7 +76,7 @@ public extension DataService {
}
}
func pageFromCache(slug: String) -> ArticleContentDep? {
func pageFromCache(slug: String) -> ArticleContent? {
// TODO: cerate highlightsJSON from stored highlights
// let fetchRequest: NSFetchRequest<Models.LinkedItem> = LinkedItem.fetchRequest()
// fetchRequest.predicate = NSPredicate(
@ -98,7 +98,7 @@ public extension DataService {
)
if let articleContent = (try? persistentContainer.viewContext.fetch(fetchRequest))?.first {
return ArticleContentDep(
return ArticleContent(
htmlContent: articleContent.htmlContent ?? "",
highlightsJSONString: articleContent.highlightsJSONString ?? ""
)

View file

@ -5,19 +5,19 @@ import Models
import SwiftGraphQL
public extension DataService {
struct ArticleContent {
struct ArticleProps {
let htmlContent: String
let highlights: [InternalHighlight]
}
func articleContentPublisher(username: String, slug: String) -> AnyPublisher<ArticleContentDep, ServerError> {
func articleContentPublisher(username: String, slug: String) -> AnyPublisher<ArticleContent, ServerError> {
enum QueryResult {
case success(result: ArticleContent)
case success(result: ArticleProps)
case error(error: String)
}
let articleSelection = Selection.Article {
ArticleContent(
ArticleProps(
htmlContent: try $0.content(),
highlights: try $0.highlights(selection: highlightSelection.list)
)
@ -56,7 +56,7 @@ public extension DataService {
highlightsJSONString: highlightsJSONString
)
promise(.success(
ArticleContentDep(
ArticleContent(
htmlContent: result.htmlContent,
highlightsJSONString: highlightsJSONString
))