ReadKeep/readeck/Domain/UseCase/GetBookmarksUseCase.swift
Ilyas Hallak 3e6db364b5 Add bookmark labels functionality
- Add BookmarkLabel model and DTO
- Create LabelsRepository and PLabelsRepository protocol
- Add GetLabelsUseCase for fetching labels
- Update BookmarkMapper to handle labels
- Add LabelsView and LabelsViewModel for UI
- Update BookmarksView and BookmarkLabelsView to display labels
- Add green2 color asset for labels
- Update API and repository layers to support labels
2025-07-09 22:28:19 +02:00

31 lines
1.1 KiB
Swift

import Foundation
class GetBookmarksUseCase {
private let repository: PBookmarksRepository
init(repository: PBookmarksRepository) {
self.repository = repository
}
func execute(state: BookmarkState? = nil, limit: Int? = nil, offset: Int? = nil, search: String? = nil, type: [BookmarkType]? = nil, tag: String? = nil) async throws -> BookmarksPage {
var allBookmarks = try await repository.fetchBookmarks(state: state, limit: limit, offset: offset, search: search, type: type, tag: tag)
if let state = state {
allBookmarks.bookmarks = allBookmarks.bookmarks.filter { bookmark in
switch state {
case .all:
return true
case .unread:
return !bookmark.isArchived && !bookmark.isMarked
case .favorite:
return bookmark.isMarked
case .archived:
return bookmark.isArchived
}
}
}
return allBookmarks
}
}