- Split TabView and Sidebar logic into PhoneTabView, PadSidebarView, SidebarTab, and BookmarkState for better device adaptation - Remove old SettingsViewModel, introduce SettingsGeneralViewModel and SettingsServerViewModel for modular settings - Update BookmarksView and BookmarksViewModel for new paginated and filtered data model - Clean up and modularize settings UI (SettingsGeneralView, SettingsServerView, FontSettingsView) - Remove obsolete files (old TabView, File.swift, SettingsViewModel, etc.) - Add BookmarksPageDto and update related data flow - Various UI/UX improvements and code cleanup BREAKING: Settings and navigation structure refactored, old settings logic removed
31 lines
1.0 KiB
Swift
31 lines
1.0 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) async throws -> BookmarksPage {
|
|
var allBookmarks = try await repository.fetchBookmarks(state: state, limit: limit, offset: offset, search: search, type: type)
|
|
|
|
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
|
|
}
|
|
}
|