From 40d0c52c2e5879c6cdf30e6b04944f933fbeeab0 Mon Sep 17 00:00:00 2001 From: Jackson Harper Date: Fri, 7 Apr 2023 17:26:06 +0800 Subject: [PATCH] Set page notes if they are already created --- .../Sources/App/Views/Highlights/HighlightsListCard.swift | 1 + .../Sources/App/Views/Highlights/NotebookView.swift | 7 +++++-- .../Sources/App/Views/Highlights/NotebookViewModel.swift | 7 +++++++ .../Sources/App/Views/Home/HomeFeedViewIOS.swift | 4 ---- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/apple/OmnivoreKit/Sources/App/Views/Highlights/HighlightsListCard.swift b/apple/OmnivoreKit/Sources/App/Views/Highlights/HighlightsListCard.swift index d22fcd593..42cc66a7e 100644 --- a/apple/OmnivoreKit/Sources/App/Views/Highlights/HighlightsListCard.swift +++ b/apple/OmnivoreKit/Sources/App/Views/Highlights/HighlightsListCard.swift @@ -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 diff --git a/apple/OmnivoreKit/Sources/App/Views/Highlights/NotebookView.swift b/apple/OmnivoreKit/Sources/App/Views/Highlights/NotebookView.swift index 42c894f8c..417bd161e 100644 --- a/apple/OmnivoreKit/Sources/App/Views/Highlights/NotebookView.swift +++ b/apple/OmnivoreKit/Sources/App/Views/Highlights/NotebookView.swift @@ -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 }, diff --git a/apple/OmnivoreKit/Sources/App/Views/Highlights/NotebookViewModel.swift b/apple/OmnivoreKit/Sources/App/Views/Highlights/NotebookViewModel.swift index 4c0ff7dd5..1dd96bfd5 100644 --- a/apple/OmnivoreKit/Sources/App/Views/Highlights/NotebookViewModel.swift +++ b/apple/OmnivoreKit/Sources/App/Views/Highlights/NotebookViewModel.swift @@ -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 } diff --git a/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewIOS.swift b/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewIOS.swift index 1e17887b7..6a4a24788 100644 --- a/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewIOS.swift +++ b/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewIOS.swift @@ -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") }