ReadKeep/readeck/Domain/UseCase/AddTextToSpeechQueueUseCase.swift
Ilyas Hallak 930779169b feat: introduce protocol-based UseCase architecture and mock factory
- Add protocols for all UseCases and implement them in their respective classes
- Add DefaultUseCaseFactory and MockUseCaseFactory for dependency injection
- Implement all mock UseCases with dummy data
- Start migration of view models and views to protocol-based UseCase injection (not all migrated yet)
- Refactor previews and some initializers for easier testing
- Move SectionHeader to Components, update server settings UI text
- Add sample article.html for mock content
2025-07-18 00:46:07 +02:00

24 lines
659 B
Swift

import Foundation
protocol PAddTextToSpeechQueueUseCase {
func execute(bookmarkDetail: BookmarkDetail)
}
class AddTextToSpeechQueueUseCase: PAddTextToSpeechQueueUseCase {
private let speechQueue: SpeechQueue
init(speechQueue: SpeechQueue = .shared) {
self.speechQueue = speechQueue
}
func execute(bookmarkDetail: BookmarkDetail) {
var text = bookmarkDetail.title + "\n"
if let content = bookmarkDetail.content {
text += content.stripHTML
} else {
text += bookmarkDetail.description.stripHTML
}
speechQueue.enqueue(bookmarkDetail.toSpeechQueueItem(text))
}
}