mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
remove performActionSubject from web wrapper view model
This commit is contained in:
parent
824c889ec6
commit
05574a640e
2 changed files with 21 additions and 43 deletions
|
|
@ -76,21 +76,11 @@ enum PDFProvider {
|
|||
queryParams: ["isAppEmbedView": "true", "highlightBarDisabled": isMacApp ? "false" : "true"]
|
||||
)
|
||||
|
||||
let newWebAppWrapperViewModel = WebAppWrapperViewModel(
|
||||
webAppWrapperViewModel = WebAppWrapperViewModel(
|
||||
webViewURLRequest: urlRequest,
|
||||
baseURL: baseURL,
|
||||
rawAuthCookie: rawAuthCookie
|
||||
)
|
||||
|
||||
newWebAppWrapperViewModel.performActionSubject.sink { action in
|
||||
switch action {
|
||||
case let .shareHighlight(highlightID):
|
||||
print("show share modal for highlight with id: \(highlightID)")
|
||||
}
|
||||
}
|
||||
.store(in: &newWebAppWrapperViewModel.subscriptions)
|
||||
|
||||
webAppWrapperViewModel = newWebAppWrapperViewModel
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
import Combine
|
||||
import SafariServices
|
||||
import SwiftUI
|
||||
import WebKit
|
||||
|
|
@ -8,8 +7,6 @@ public final class WebAppWrapperViewModel: ObservableObject {
|
|||
case shareHighlight(highlightID: String)
|
||||
}
|
||||
|
||||
public var subscriptions = Set<AnyCancellable>()
|
||||
public let performActionSubject = PassthroughSubject<Action, Never>()
|
||||
let webViewURLRequest: URLRequest
|
||||
let baseURL: URL
|
||||
let rawAuthCookie: String?
|
||||
|
|
@ -43,27 +40,25 @@ public struct WebAppWrapperView: View {
|
|||
}
|
||||
|
||||
public var body: some View {
|
||||
let webAppView = WebAppView(
|
||||
request: viewModel.webViewURLRequest,
|
||||
baseURL: viewModel.baseURL,
|
||||
rawAuthCookie: viewModel.rawAuthCookie,
|
||||
openLinkAction: {
|
||||
#if os(macOS)
|
||||
NSWorkspace.shared.open($0)
|
||||
#elseif os(iOS)
|
||||
safariWebLink = SafariWebLink(id: UUID(), url: $0)
|
||||
#endif
|
||||
},
|
||||
webViewActionHandler: webViewActionHandler,
|
||||
navBarVisibilityRatioUpdater: navBarVisibilityRatioUpdater,
|
||||
annotation: $annotation,
|
||||
annotationSaveTransactionID: $annotationSaveTransactionID,
|
||||
sendIncreaseFontSignal: $viewModel.sendIncreaseFontSignal,
|
||||
sendDecreaseFontSignal: $viewModel.sendDecreaseFontSignal
|
||||
)
|
||||
|
||||
return VStack {
|
||||
webAppView
|
||||
VStack {
|
||||
WebAppView(
|
||||
request: viewModel.webViewURLRequest,
|
||||
baseURL: viewModel.baseURL,
|
||||
rawAuthCookie: viewModel.rawAuthCookie,
|
||||
openLinkAction: {
|
||||
#if os(macOS)
|
||||
NSWorkspace.shared.open($0)
|
||||
#elseif os(iOS)
|
||||
safariWebLink = SafariWebLink(id: UUID(), url: $0)
|
||||
#endif
|
||||
},
|
||||
webViewActionHandler: webViewActionHandler,
|
||||
navBarVisibilityRatioUpdater: navBarVisibilityRatioUpdater,
|
||||
annotation: $annotation,
|
||||
annotationSaveTransactionID: $annotationSaveTransactionID,
|
||||
sendIncreaseFontSignal: $viewModel.sendIncreaseFontSignal,
|
||||
sendDecreaseFontSignal: $viewModel.sendDecreaseFontSignal
|
||||
)
|
||||
}
|
||||
.sheet(item: $safariWebLink) {
|
||||
SafariView(url: $0.url)
|
||||
|
|
@ -92,16 +87,9 @@ public struct WebAppWrapperView: View {
|
|||
guard let messageBody = message.body as? [String: String] else { return }
|
||||
guard let actionID = messageBody["actionID"] else { return }
|
||||
|
||||
switch actionID {
|
||||
case "share":
|
||||
if let highlightId = messageBody["highlightID"] {
|
||||
viewModel.performActionSubject.send(.shareHighlight(highlightID: highlightId))
|
||||
}
|
||||
case "annotate":
|
||||
if actionID == "annotate" {
|
||||
annotation = messageBody["annotation"] ?? ""
|
||||
showHighlightAnnotationModal = true
|
||||
default:
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue