Implemented ability to delete annotations via swipe-to-delete gesture in the annotations list view. Added close button with X icon to dismiss the annotations sheet. Changes: - Added DeleteAnnotationUseCase with repository integration - Extended API with DELETE endpoint for annotations - Implemented swipe-to-delete in AnnotationsListView - Added error handling and optimistic UI updates - Updated toolbar with close button (X icon)
29 lines
880 B
Swift
29 lines
880 B
Swift
import Foundation
|
|
|
|
class AnnotationsRepository: PAnnotationsRepository {
|
|
private let api: PAPI
|
|
|
|
init(api: PAPI) {
|
|
self.api = api
|
|
}
|
|
|
|
func fetchAnnotations(bookmarkId: String) async throws -> [Annotation] {
|
|
let annotationDtos = try await api.getBookmarkAnnotations(bookmarkId: bookmarkId)
|
|
return annotationDtos.map { dto in
|
|
Annotation(
|
|
id: dto.id,
|
|
text: dto.text,
|
|
created: dto.created,
|
|
startOffset: dto.startOffset,
|
|
endOffset: dto.endOffset,
|
|
startSelector: dto.startSelector,
|
|
endSelector: dto.endSelector
|
|
)
|
|
}
|
|
}
|
|
|
|
func deleteAnnotation(bookmarkId: String, annotationId: String) async throws {
|
|
try await api.deleteAnnotation(bookmarkId: bookmarkId, annotationId: annotationId)
|
|
}
|
|
}
|