mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
Add highlight notes from the notebook
This commit is contained in:
parent
42a3b2fe87
commit
f60ba672e7
3 changed files with 15 additions and 4 deletions
|
|
@ -46,6 +46,7 @@
|
|||
}.alert("Are you sure you want to delete the note?",
|
||||
isPresented: $showConfirmNoteDelete) {
|
||||
Button("Remove Item", role: .destructive) {
|
||||
viewModel.deleteNote(dataService: dataService)
|
||||
showConfirmNoteDelete = false
|
||||
}
|
||||
Button(LocalText.cancelGeneric, role: .cancel) {
|
||||
|
|
|
|||
|
|
@ -55,13 +55,23 @@ struct NoteItemParams: Identifiable {
|
|||
|
||||
if let linkedItem = dataService.viewContext.object(with: itemObjectID) as? LinkedItem {
|
||||
noteItem = NoteItemParams(highlightID: highlightId, annotation: annotation)
|
||||
let highlight = dataService.createNote(shortId: shortId, highlightID: highlightId, articleId: linkedItem.unwrappedID, annotation: annotation)
|
||||
let highlight = dataService.createNote(shortId: shortId,
|
||||
highlightID: highlightId,
|
||||
articleId: linkedItem.unwrappedID,
|
||||
annotation: annotation)
|
||||
} else {
|
||||
//
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func deleteNote(dataService: DataService) {
|
||||
if let highlightID = noteItem?.highlightID {
|
||||
dataService.deleteHighlight(highlightID: highlightID)
|
||||
noteItem = nil
|
||||
}
|
||||
}
|
||||
|
||||
func deleteHighlight(highlightID: String, dataService: DataService) {
|
||||
dataService.deleteHighlight(highlightID: highlightID)
|
||||
highlightItems.removeAll { $0.highlightID == highlightID }
|
||||
|
|
|
|||
|
|
@ -91,10 +91,10 @@ public extension DataService {
|
|||
articleId: articleId,
|
||||
highlightPositionAnchorIndex: OptionalArgument(highlight.positionAnchorIndex),
|
||||
highlightPositionPercent: OptionalArgument(highlight.positionPercent), id: highlight.id,
|
||||
patch: OptionalArgument(highlight.patch),
|
||||
quote: OptionalArgument(highlight.quote),
|
||||
patch: OptionalArgument(highlight.patch.isEmpty ? nil : highlight.patch),
|
||||
quote: OptionalArgument(highlight.quote.isEmpty ? nil : highlight.quote),
|
||||
shortId: highlight.shortId,
|
||||
type: OptionalArgument(Enums.HighlightType.highlight)
|
||||
type: OptionalArgument(highlight.type == "NOTE" ? Enums.HighlightType.note : Enums.HighlightType.highlight)
|
||||
),
|
||||
selection: selection
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in a new issue