update reading progress on the item in home view model

This commit is contained in:
Satindar Dhillon 2022-03-09 07:42:58 -08:00
parent 525cb9b8b9
commit f7f21300f3
2 changed files with 8 additions and 1 deletions

View file

@ -158,4 +158,11 @@ final class HomeFeedViewModel: ObservableObject {
)
.store(in: &subscriptions)
}
func updateProgress(itemID: String, progress: Double) {
guard let item = items.first(where: { $0.id == itemID }) else { return }
if let index = items.firstIndex(of: item) {
items[index].readingProgress = progress
}
}
}

View file

@ -92,7 +92,7 @@ final class LinkItemDetailViewModel: ObservableObject {
case let .shareHighlight(highlightID):
print("show share modal for highlight with id: \(highlightID)")
case let .updateReadingProgess(progress: progress):
self?.item.readingProgress = Double(progress)
self?.homeFeedViewModel.updateProgress(itemID: self?.item.id ?? "", progress: Double(progress))
}
}
.store(in: &newWebAppWrapperViewModel.subscriptions)