Add comprehensive annotations feature to bookmark detail views: - Implement annotations list view with date formatting and state machine - Add CSS-based highlighting for rd-annotation tags in WebView components - Support Readeck color scheme (yellow, green, blue, red) for annotations - Enable tap-to-scroll functionality to navigate to selected annotations - Integrate annotations button in bookmark detail toolbar - Add API endpoint and repository layer for fetching annotations
30 lines
809 B
Swift
30 lines
809 B
Swift
import Foundation
|
|
|
|
@Observable
|
|
class AnnotationsListViewModel {
|
|
private let getAnnotationsUseCase: PGetBookmarkAnnotationsUseCase
|
|
|
|
var annotations: [Annotation] = []
|
|
var isLoading = false
|
|
var errorMessage: String?
|
|
var showErrorAlert = false
|
|
|
|
init(_ factory: UseCaseFactory = DefaultUseCaseFactory.shared) {
|
|
self.getAnnotationsUseCase = factory.makeGetBookmarkAnnotationsUseCase()
|
|
}
|
|
|
|
@MainActor
|
|
func loadAnnotations(for bookmarkId: String) async {
|
|
isLoading = true
|
|
errorMessage = nil
|
|
defer { isLoading = false }
|
|
|
|
do {
|
|
annotations = try await getAnnotationsUseCase.execute(bookmarkId: bookmarkId)
|
|
} catch {
|
|
errorMessage = "Failed to load annotations"
|
|
showErrorAlert = true
|
|
}
|
|
}
|
|
}
|