- Add PATCH API endpoint for updating bookmarks with toggle functions - Add DELETE API endpoint for permanent bookmark deletion - Implement UpdateBookmarkUseCase with convenience methods for common actions - Implement DeleteBookmarkUseCase for permanent bookmark removal - Create BookmarkUpdateRequest domain model with builder pattern - Extend BookmarkCardView with action menu and confirmation dialog - Add context-sensitive actions based on current bookmark state - Implement optimistic updates in BookmarksViewModel - Add error handling and recovery for failed operations - Enhance UI with badges, progress indicators, and action buttons
44 lines
1.8 KiB
Swift
44 lines
1.8 KiB
Swift
import Foundation
|
|
|
|
class UpdateBookmarkUseCase {
|
|
private let repository: PBookmarksRepository
|
|
|
|
init(repository: PBookmarksRepository) {
|
|
self.repository = repository
|
|
}
|
|
|
|
func execute(bookmarkId: String, updateRequest: BookmarkUpdateRequest) async throws {
|
|
try await repository.updateBookmark(id: bookmarkId, updateRequest: updateRequest)
|
|
}
|
|
|
|
// Convenience methods für häufige Aktionen
|
|
func toggleArchive(bookmarkId: String, isArchived: Bool) async throws {
|
|
let request = BookmarkUpdateRequest.archive(isArchived)
|
|
try await execute(bookmarkId: bookmarkId, updateRequest: request)
|
|
}
|
|
|
|
func toggleFavorite(bookmarkId: String, isMarked: Bool) async throws {
|
|
let request = BookmarkUpdateRequest.favorite(isMarked)
|
|
try await execute(bookmarkId: bookmarkId, updateRequest: request)
|
|
}
|
|
|
|
func markAsDeleted(bookmarkId: String) async throws {
|
|
let request = BookmarkUpdateRequest.delete(true)
|
|
try await execute(bookmarkId: bookmarkId, updateRequest: request)
|
|
}
|
|
|
|
func updateReadProgress(bookmarkId: String, progress: Int, anchor: String? = nil) async throws {
|
|
let request = BookmarkUpdateRequest.updateProgress(progress, anchor: anchor)
|
|
try await execute(bookmarkId: bookmarkId, updateRequest: request)
|
|
}
|
|
|
|
func updateTitle(bookmarkId: String, title: String) async throws {
|
|
let request = BookmarkUpdateRequest.updateTitle(title)
|
|
try await execute(bookmarkId: bookmarkId, updateRequest: request)
|
|
}
|
|
|
|
func updateLabels(bookmarkId: String, labels: [String]) async throws {
|
|
let request = BookmarkUpdateRequest.updateLabels(labels)
|
|
try await execute(bookmarkId: bookmarkId, updateRequest: request)
|
|
}
|
|
} |