From b1b3915b7b245e67cf018abc52dd4ea020ff11ae Mon Sep 17 00:00:00 2001 From: Satindar Dhillon Date: Wed, 9 Mar 2022 08:25:54 -0800 Subject: [PATCH] send reading progress updates for ipad grid only --- .../Sources/App/Views/Home/HomeFeedViewIOS.swift | 6 ++++++ .../Sources/App/Views/Home/HomeFeedViewModel.swift | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewIOS.swift b/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewIOS.swift index b74242259..04a07ba01 100644 --- a/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewIOS.swift +++ b/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewIOS.swift @@ -270,6 +270,9 @@ import Views } } .listStyle(PlainListStyle()) + .onAppear { + viewModel.sendProgressUpdates = false + } } } @@ -347,6 +350,9 @@ import Views LoadingSection() } } + .onAppear { + viewModel.sendProgressUpdates = true + } } } diff --git a/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewModel.swift b/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewModel.swift index 011c1dba6..e0ebabb8d 100644 --- a/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewModel.swift +++ b/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewModel.swift @@ -12,6 +12,7 @@ final class HomeFeedViewModel: ObservableObject { @Published var isLoading = false @Published var showPushNotificationPrimer = false var cursor: String? + var sendProgressUpdates = false // These are used to make sure we handle search result // responses in the right order @@ -160,7 +161,7 @@ final class HomeFeedViewModel: ObservableObject { } func updateProgress(itemID: String, progress: Double) { - guard let item = items.first(where: { $0.id == itemID }) else { return } + guard sendProgressUpdates, let item = items.first(where: { $0.id == itemID }) else { return } if let index = items.firstIndex(of: item) { items[index].readingProgress = progress }