From 6658d1d69b883a7cd5a6b75eec3fc137163f9f37 Mon Sep 17 00:00:00 2001 From: Satindar Dhillon Date: Wed, 20 Apr 2022 15:19:09 -0700 Subject: [PATCH] rename article content models to avoid clashing --- .../App/Views/WebReader/WebReaderViewModel.swift | 2 +- .../{ArticleContentDep.swift => ArticleContent.swift} | 2 +- .../Sources/Services/DataService/DataService.swift | 4 ++-- .../DataService/Queries/ArticleContentQuery.swift | 10 +++++----- 4 files changed, 9 insertions(+), 9 deletions(-) rename apple/OmnivoreKit/Sources/Models/DataModels/{ArticleContentDep.swift => ArticleContent.swift} (88%) diff --git a/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReaderViewModel.swift b/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReaderViewModel.swift index 55d3d4cec..8795a0177 100644 --- a/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReaderViewModel.swift +++ b/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReaderViewModel.swift @@ -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() diff --git a/apple/OmnivoreKit/Sources/Models/DataModels/ArticleContentDep.swift b/apple/OmnivoreKit/Sources/Models/DataModels/ArticleContent.swift similarity index 88% rename from apple/OmnivoreKit/Sources/Models/DataModels/ArticleContentDep.swift rename to apple/OmnivoreKit/Sources/Models/DataModels/ArticleContent.swift index 2587c1152..7f21779c2 100644 --- a/apple/OmnivoreKit/Sources/Models/DataModels/ArticleContentDep.swift +++ b/apple/OmnivoreKit/Sources/Models/DataModels/ArticleContent.swift @@ -1,6 +1,6 @@ import Foundation -public struct ArticleContentDep { +public struct ArticleContent { public let htmlContent: String public let highlightsJSONString: String diff --git a/apple/OmnivoreKit/Sources/Services/DataService/DataService.swift b/apple/OmnivoreKit/Sources/Services/DataService/DataService.swift index 845369ea6..28eb22996 100644 --- a/apple/OmnivoreKit/Sources/Services/DataService/DataService.swift +++ b/apple/OmnivoreKit/Sources/Services/DataService/DataService.swift @@ -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 = 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 ?? "" ) diff --git a/apple/OmnivoreKit/Sources/Services/DataService/Queries/ArticleContentQuery.swift b/apple/OmnivoreKit/Sources/Services/DataService/Queries/ArticleContentQuery.swift index 0b982b4b4..2e60be20b 100644 --- a/apple/OmnivoreKit/Sources/Services/DataService/Queries/ArticleContentQuery.swift +++ b/apple/OmnivoreKit/Sources/Services/DataService/Queries/ArticleContentQuery.swift @@ -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 { + func articleContentPublisher(username: String, slug: String) -> AnyPublisher { 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 ))