- 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
61 lines
2.2 KiB
Swift
61 lines
2.2 KiB
Swift
import Foundation
|
|
|
|
protocol UseCaseFactory {
|
|
func makeLoginUseCase() -> LoginUseCase
|
|
func makeGetBookmarksUseCase() -> GetBookmarksUseCase
|
|
func makeGetBookmarkUseCase() -> GetBookmarkUseCase
|
|
func makeGetBookmarkArticleUseCase() -> GetBookmarkArticleUseCase
|
|
func makeSaveSettingsUseCase() -> SaveSettingsUseCase
|
|
func makeLoadSettingsUseCase() -> LoadSettingsUseCase
|
|
func makeUpdateBookmarkUseCase() -> UpdateBookmarkUseCase
|
|
func makeDeleteBookmarkUseCase() -> DeleteBookmarkUseCase
|
|
}
|
|
|
|
class DefaultUseCaseFactory: UseCaseFactory {
|
|
private let tokenProvider = CoreDataTokenProvider()
|
|
private lazy var api: PAPI = API(tokenProvider: tokenProvider)
|
|
private lazy var authRepository: PAuthRepository = AuthRepository(api: api, settingsRepository: SettingsRepository())
|
|
private lazy var bookmarksRepository: PBookmarksRepository = BookmarksRepository(api: api)
|
|
|
|
static let shared = DefaultUseCaseFactory()
|
|
|
|
private init() {}
|
|
|
|
func makeLoginUseCase() -> LoginUseCase {
|
|
LoginUseCase(repository: authRepository)
|
|
}
|
|
|
|
func makeGetBookmarksUseCase() -> GetBookmarksUseCase {
|
|
GetBookmarksUseCase(repository: bookmarksRepository)
|
|
}
|
|
|
|
func makeGetBookmarkUseCase() -> GetBookmarkUseCase {
|
|
GetBookmarkUseCase(repository: bookmarksRepository)
|
|
}
|
|
|
|
func makeGetBookmarkArticleUseCase() -> GetBookmarkArticleUseCase {
|
|
GetBookmarkArticleUseCase(repository: bookmarksRepository)
|
|
}
|
|
|
|
func makeSaveSettingsUseCase() -> SaveSettingsUseCase {
|
|
SaveSettingsUseCase(authRepository: authRepository)
|
|
}
|
|
|
|
func makeLoadSettingsUseCase() -> LoadSettingsUseCase {
|
|
LoadSettingsUseCase(authRepository: authRepository)
|
|
}
|
|
|
|
func makeUpdateBookmarkUseCase() -> UpdateBookmarkUseCase {
|
|
return UpdateBookmarkUseCase(repository: bookmarksRepository)
|
|
}
|
|
|
|
// Nicht mehr nötig - Token wird automatisch geladen
|
|
func refreshConfiguration() async {
|
|
// Optional: Cache löschen falls nötig
|
|
}
|
|
|
|
func makeDeleteBookmarkUseCase() -> DeleteBookmarkUseCase {
|
|
return DeleteBookmarkUseCase(repository: bookmarksRepository)
|
|
}
|
|
}
|