delete progress updating delay code
This commit is contained in:
@ -77,9 +77,6 @@ import Views
|
||||
viewModel.loadItems(dataService: dataService, isRefresh: true)
|
||||
}
|
||||
}
|
||||
.onChange(of: viewModel.selectedLinkItem) { _ in
|
||||
viewModel.commitItemUpdates()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -9,9 +9,6 @@ import Views
|
||||
@MainActor final class HomeFeedViewModel: ObservableObject {
|
||||
var currentDetailViewModel: LinkItemDetailViewModel?
|
||||
|
||||
/// Track progress updates to be committed when user navigates back to grid view
|
||||
var uncommittedReadingProgressUpdates = [String: Double]()
|
||||
|
||||
@Published var items = [LinkedItem]()
|
||||
@Published var isLoading = false
|
||||
@Published var showPushNotificationPrimer = false
|
||||
@ -181,16 +178,6 @@ import Views
|
||||
.store(in: &subscriptions)
|
||||
}
|
||||
|
||||
/// Update `FeedItem`s with the cached reading progress and label values so it can animate when the
|
||||
/// user navigates back to the grid view (and also avoid mutations of the grid items
|
||||
/// that can cause the `NavigationView` to pop.
|
||||
func commitItemUpdates() {
|
||||
for (key, value) in uncommittedReadingProgressUpdates {
|
||||
updateProgress(itemID: key, progress: value)
|
||||
}
|
||||
uncommittedReadingProgressUpdates = [:]
|
||||
}
|
||||
|
||||
private func updateProgress(itemID: String, progress: Double) {
|
||||
guard let item = items.first(where: { $0.id == itemID }) else { return }
|
||||
if let index = items.firstIndex(of: item) {
|
||||
|
||||
@ -90,8 +90,6 @@ enum PDFProvider {
|
||||
switch action {
|
||||
case let .shareHighlight(highlightID):
|
||||
print("show share modal for highlight with id: \(highlightID)")
|
||||
case let .updateReadingProgess(progress: progress):
|
||||
self?.homeFeedViewModel.uncommittedReadingProgressUpdates[self?.item.id ?? ""] = Double(progress)
|
||||
}
|
||||
}
|
||||
.store(in: &newWebAppWrapperViewModel.subscriptions)
|
||||
|
||||
@ -33,14 +33,6 @@ import WebKit
|
||||
}
|
||||
|
||||
func webViewActionHandler(message: WKScriptMessage, replyHandler: WKScriptMessageReplyHandler?) {
|
||||
if message.name == WebViewAction.readingProgressUpdate.rawValue {
|
||||
let messageBody = message.body as? [String: Double]
|
||||
|
||||
if let messageBody = messageBody, let progress = messageBody["progress"] {
|
||||
homeFeedViewModel.uncommittedReadingProgressUpdates[item.unwrappedID] = Double(progress)
|
||||
}
|
||||
}
|
||||
|
||||
if let replyHandler = replyHandler {
|
||||
viewModel.webViewActionWithReplyHandler(
|
||||
message: message,
|
||||
@ -53,12 +45,6 @@ import WebKit
|
||||
if message.name == WebViewAction.highlightAction.rawValue {
|
||||
handleHighlightAction(message: message)
|
||||
}
|
||||
|
||||
if message.name == WebViewAction.readingProgressUpdate.rawValue {
|
||||
guard let messageBody = message.body as? [String: Double] else { return }
|
||||
guard let progress = messageBody["progress"] else { return }
|
||||
homeFeedViewModel.uncommittedReadingProgressUpdates[item.unwrappedID] = Double(progress)
|
||||
}
|
||||
}
|
||||
|
||||
private func handleHighlightAction(message: WKScriptMessage) {
|
||||
|
||||
@ -6,7 +6,6 @@ import WebKit
|
||||
public final class WebAppWrapperViewModel: ObservableObject {
|
||||
public enum Action {
|
||||
case shareHighlight(highlightID: String)
|
||||
case updateReadingProgess(progress: Int)
|
||||
}
|
||||
|
||||
public var subscriptions = Set<AnyCancellable>()
|
||||
@ -87,12 +86,6 @@ public struct WebAppWrapperView: View {
|
||||
if message.name == WebViewAction.highlightAction.rawValue {
|
||||
handleHighlightAction(message: message)
|
||||
}
|
||||
|
||||
if message.name == WebViewAction.readingProgressUpdate.rawValue {
|
||||
guard let messageBody = message.body as? [String: Double] else { return }
|
||||
guard let progress = messageBody["progress"] else { return }
|
||||
viewModel.performActionSubject.send(.updateReadingProgess(progress: Int(progress)))
|
||||
}
|
||||
}
|
||||
|
||||
private func handleHighlightAction(message: WKScriptMessage) {
|
||||
|
||||
Reference in New Issue
Block a user