mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
update item reading progress when signal is ent from web app view
This commit is contained in:
parent
ddb13770d3
commit
525cb9b8b9
2 changed files with 6 additions and 6 deletions
|
|
@ -87,12 +87,12 @@ final class LinkItemDetailViewModel: ObservableObject {
|
|||
rawAuthCookie: rawAuthCookie
|
||||
)
|
||||
|
||||
newWebAppWrapperViewModel.performActionSubject.sink { action in
|
||||
newWebAppWrapperViewModel.performActionSubject.sink { [weak self] action in
|
||||
switch action {
|
||||
case let .shareHighlight(highlightID):
|
||||
print("show share modal for highlight with id: \(highlightID)")
|
||||
case let .updateReadingProgess(progress: progress):
|
||||
print("new reading progress: \(progress)")
|
||||
self?.item.readingProgress = Double(progress)
|
||||
}
|
||||
}
|
||||
.store(in: &newWebAppWrapperViewModel.subscriptions)
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import WebKit
|
|||
public final class WebAppWrapperViewModel: ObservableObject {
|
||||
public enum Action {
|
||||
case shareHighlight(highlightID: String)
|
||||
case updateReadingProgess(progress: Double)
|
||||
case updateReadingProgess(progress: Int)
|
||||
}
|
||||
|
||||
public var subscriptions = Set<AnyCancellable>()
|
||||
|
|
@ -87,11 +87,11 @@ 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: String] else { return }
|
||||
guard let messageBody = message.body as? [String: Double] else { return }
|
||||
guard let progress = messageBody["progress"] else { return }
|
||||
print(progress)
|
||||
viewModel.performActionSubject.send(.updateReadingProgess(progress: Int(progress)))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue