Set page notes if they are already created

This commit is contained in:
Jackson Harper
2023-04-07 17:26:06 +08:00
parent 4fcc49148a
commit 40d0c52c2e
4 changed files with 13 additions and 6 deletions

View File

@ -12,6 +12,7 @@
let viewModel: NotebookViewModel
let highlightParams: HighlightListItemParams
@Binding var hasHighlightMutations: Bool
let onSaveAnnotation: (String) -> Void
let onDeleteHighlight: () -> Void
let onSetLabels: (String) -> Void

View File

@ -81,7 +81,7 @@
}
}
.onTapGesture {
// annotation = highlightParams.annotation
noteAnnotation = viewModel.noteItem?.annotation ?? ""
showAnnotationModal = true
}
}
@ -138,7 +138,10 @@
HighlightAnnotationSheet(
annotation: $noteAnnotation,
onSave: {
// onSaveAnnotation(annotation)
viewModel.updateNoteAnnotation(
annotation: noteAnnotation,
dataService: dataService
)
showAnnotationModal = false
hasHighlightMutations = true
},

View File

@ -45,6 +45,13 @@ struct NoteItemParams: Identifiable {
}
}
func updateNoteAnnotation(annotation: String, dataService: DataService) {
if let noteItem = self.noteItem {
dataService.updateHighlightAttributes(highlightID: noteItem.highlightID, annotation: annotation)
self.noteItem = NoteItemParams(highlightID: noteItem.highlightID, annotation: annotation)
}
}
func deleteHighlight(highlightID: String, dataService: DataService) {
dataService.deleteHighlight(highlightID: highlightID)
highlightItems.removeAll { $0.highlightID == highlightID }

View File

@ -317,10 +317,6 @@ struct AnimatingCellHeight: AnimatableModifier {
func menuItems(for item: LinkedItem) -> some View {
Group {
Button(
action: { viewModel.itemForHighlightsView = item },
label: { Label("Notebook", systemImage: "highlighter") }
)
Button(
action: { viewModel.itemUnderTitleEdit = item },
label: { Label("Edit Info", systemImage: "info.circle") }