From cb878ba0ef40e6b4e4a0082e55228d5e80adfb27 Mon Sep 17 00:00:00 2001 From: Satindar Dhillon Date: Fri, 22 Apr 2022 10:17:06 -0700 Subject: [PATCH] return double from reading progress update publisher --- .../Sources/App/Views/LinkItemDetailView.swift | 4 ++-- .../Mutations/UpdateArticleReadingProgress.swift | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/apple/OmnivoreKit/Sources/App/Views/LinkItemDetailView.swift b/apple/OmnivoreKit/Sources/App/Views/LinkItemDetailView.swift index ee77784a3..09603a0c8 100644 --- a/apple/OmnivoreKit/Sources/App/Views/LinkItemDetailView.swift +++ b/apple/OmnivoreKit/Sources/App/Views/LinkItemDetailView.swift @@ -39,8 +39,8 @@ enum PDFProvider { .sink { completion in guard case let .failure(error) = completion else { return } print(error) - } receiveValue: { [weak self] feedItem in - self?.item.readingProgress = feedItem.readingProgress + } receiveValue: { [weak self] readingProgress in + self?.item.readingProgress = readingProgress } .store(in: &subscriptions) } diff --git a/apple/OmnivoreKit/Sources/Services/DataService/Mutations/UpdateArticleReadingProgress.swift b/apple/OmnivoreKit/Sources/Services/DataService/Mutations/UpdateArticleReadingProgress.swift index 9ead9107a..1b5b503c5 100644 --- a/apple/OmnivoreKit/Sources/Services/DataService/Mutations/UpdateArticleReadingProgress.swift +++ b/apple/OmnivoreKit/Sources/Services/DataService/Mutations/UpdateArticleReadingProgress.swift @@ -9,9 +9,9 @@ public extension DataService { itemID: String, readingProgress: Double, anchorIndex: Int - ) -> AnyPublisher { + ) -> AnyPublisher { enum MutationResult { - case saved(feedItem: FeedItemDep) + case saved(readingProgress: Double) case error(errorCode: Enums.SaveArticleReadingProgressErrorCode) } @@ -19,7 +19,7 @@ public extension DataService { try $0.on( saveArticleReadingProgressSuccess: .init { .saved( - feedItem: try $0.updatedArticle(selection: homeFeedItemSelection) + readingProgress: try $0.updatedArticle(selection: Selection.Article { try $0.readingProgressPercent() }) ) }, saveArticleReadingProgressError: .init { .error(errorCode: try $0.errorCodes().first ?? .badData) } @@ -50,7 +50,7 @@ public extension DataService { } switch payload.data { - case let .saved(feedItem): + case .saved: if let linkedItem = LinkedItem.lookup(byID: itemID, inContext: self.backgroundContext) { linkedItem.update( inContext: self.backgroundContext, @@ -58,7 +58,7 @@ public extension DataService { newAnchorIndex: anchorIndex ) } - promise(.success(feedItem)) + promise(.success(readingProgress)) case let .error(errorCode: errorCode): switch errorCode { case .unauthorized: