message web container view when highlight view is dismissed and mutations have occurred
This commit is contained in:
@ -8,6 +8,7 @@ struct HighlightsListCard: View {
|
||||
@State var showAnnotationModal = false
|
||||
|
||||
let highlightParams: HighlightListItemParams
|
||||
@Binding var hasHighlightMutations: Bool
|
||||
let onSaveAnnotation: (String) -> Void
|
||||
|
||||
var contextMenuView: some View {
|
||||
@ -111,6 +112,7 @@ struct HighlightsListCard: View {
|
||||
onSave: {
|
||||
onSaveAnnotation(annotation)
|
||||
showAnnotationModal = false
|
||||
hasHighlightMutations = true
|
||||
},
|
||||
onCancel: {
|
||||
showAnnotationModal = false
|
||||
|
||||
@ -10,12 +10,16 @@ struct HighlightsListView: View {
|
||||
@StateObject var viewModel = HighlightsListViewModel()
|
||||
|
||||
let itemObjectID: NSManagedObjectID
|
||||
@Binding var hasHighlightMutations: Bool
|
||||
|
||||
var innerBody: some View {
|
||||
List {
|
||||
Section {
|
||||
ForEach(viewModel.highlightItems) { highlightParams in
|
||||
HighlightsListCard(highlightParams: highlightParams) { newAnnotation in
|
||||
HighlightsListCard(
|
||||
highlightParams: highlightParams,
|
||||
hasHighlightMutations: $hasHighlightMutations
|
||||
) { newAnnotation in
|
||||
viewModel.updateAnnotation(
|
||||
highlightID: highlightParams.highlightID,
|
||||
annotation: newAnnotation,
|
||||
|
||||
@ -11,6 +11,7 @@ import Views
|
||||
private let enableGrid = UIDevice.isIPad || FeatureFlag.enableGridCardsOnPhone
|
||||
|
||||
struct HomeFeedContainerView: View {
|
||||
@State var hasHighlightMutations = false
|
||||
@EnvironmentObject var dataService: DataService
|
||||
@EnvironmentObject var audioController: AudioController
|
||||
|
||||
@ -63,7 +64,7 @@ import Views
|
||||
LinkedItemTitleEditView(item: item)
|
||||
}
|
||||
.sheet(item: $viewModel.itemForHighlightsView) { item in
|
||||
HighlightsListView(itemObjectID: item.objectID)
|
||||
HighlightsListView(itemObjectID: item.objectID, hasHighlightMutations: $hasHighlightMutations)
|
||||
}
|
||||
.toolbar {
|
||||
ToolbarItem(placement: .barTrailing) {
|
||||
|
||||
@ -13,6 +13,7 @@ struct WebReaderContainerView: View {
|
||||
@State private var showLabelsModal = false
|
||||
@State private var showTitleEdit = false
|
||||
@State private var showHighlightsView = false
|
||||
@State private var hasPerformedHighlightMutations = false
|
||||
@State var showHighlightAnnotationModal = false
|
||||
@State var safariWebLink: SafariWebLink?
|
||||
@State private var navBarVisibilityRatio = 1.0
|
||||
@ -44,6 +45,11 @@ struct WebReaderContainerView: View {
|
||||
}
|
||||
}
|
||||
|
||||
func onHighlightListViewDismissal() {
|
||||
print("has mutations: \(hasPerformedHighlightMutations)")
|
||||
hasPerformedHighlightMutations = false
|
||||
}
|
||||
|
||||
private func handleHighlightAction(message: WKScriptMessage) {
|
||||
guard let messageBody = message.body as? [String: String] else { return }
|
||||
guard let actionID = messageBody["actionID"] else { return }
|
||||
@ -203,8 +209,11 @@ struct WebReaderContainerView: View {
|
||||
.sheet(isPresented: $showTitleEdit) {
|
||||
LinkedItemTitleEditView(item: item)
|
||||
}
|
||||
.sheet(isPresented: $showHighlightsView) {
|
||||
HighlightsListView(itemObjectID: item.objectID)
|
||||
.sheet(isPresented: $showHighlightsView, onDismiss: onHighlightListViewDismissal) {
|
||||
HighlightsListView(
|
||||
itemObjectID: item.objectID,
|
||||
hasHighlightMutations: $hasPerformedHighlightMutations
|
||||
)
|
||||
}
|
||||
#if os(macOS)
|
||||
.buttonStyle(PlainButtonStyle())
|
||||
|
||||
Reference in New Issue
Block a user