mirror of
https://github.com/mihonapp/mihon.git
synced 2025-10-27 04:17:57 +01:00
Move some interactors to domain module
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
package tachiyomi.domain.category.interactor
|
||||
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import tachiyomi.domain.category.model.Category
|
||||
import tachiyomi.domain.category.repository.CategoryRepository
|
||||
|
||||
class GetCategories(
|
||||
private val categoryRepository: CategoryRepository,
|
||||
) {
|
||||
|
||||
fun subscribe(): Flow<List<Category>> {
|
||||
return categoryRepository.getAllAsFlow()
|
||||
}
|
||||
|
||||
fun subscribe(mangaId: Long): Flow<List<Category>> {
|
||||
return categoryRepository.getCategoriesByMangaIdAsFlow(mangaId)
|
||||
}
|
||||
|
||||
suspend fun await(): List<Category> {
|
||||
return categoryRepository.getAll()
|
||||
}
|
||||
|
||||
suspend fun await(mangaId: Long): List<Category> {
|
||||
return categoryRepository.getCategoriesByMangaId(mangaId)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package tachiyomi.domain.chapter.interactor
|
||||
|
||||
import tachiyomi.domain.chapter.model.Chapter
|
||||
|
||||
class ShouldUpdateDbChapter {
|
||||
|
||||
fun await(dbChapter: Chapter, sourceChapter: Chapter): Boolean {
|
||||
return dbChapter.scanlator != sourceChapter.scanlator || dbChapter.name != sourceChapter.name ||
|
||||
dbChapter.dateUpload != sourceChapter.dateUpload ||
|
||||
dbChapter.chapterNumber != sourceChapter.chapterNumber ||
|
||||
dbChapter.sourceOrder != sourceChapter.sourceOrder
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package tachiyomi.domain.history.interactor
|
||||
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import tachiyomi.domain.history.model.HistoryWithRelations
|
||||
import tachiyomi.domain.history.repository.HistoryRepository
|
||||
|
||||
class GetHistory(
|
||||
private val repository: HistoryRepository,
|
||||
) {
|
||||
|
||||
fun subscribe(query: String): Flow<List<HistoryWithRelations>> {
|
||||
return repository.getHistory(query)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package tachiyomi.domain.history.interactor
|
||||
|
||||
import tachiyomi.domain.history.repository.HistoryRepository
|
||||
|
||||
class GetTotalReadDuration(
|
||||
private val repository: HistoryRepository,
|
||||
) {
|
||||
|
||||
suspend fun await(): Long {
|
||||
return repository.getTotalReadDuration()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package tachiyomi.domain.history.interactor
|
||||
|
||||
import tachiyomi.domain.history.model.HistoryWithRelations
|
||||
import tachiyomi.domain.history.repository.HistoryRepository
|
||||
|
||||
class RemoveHistory(
|
||||
private val repository: HistoryRepository,
|
||||
) {
|
||||
|
||||
suspend fun awaitAll(): Boolean {
|
||||
return repository.deleteAllHistory()
|
||||
}
|
||||
|
||||
suspend fun await(history: HistoryWithRelations) {
|
||||
repository.resetHistory(history.id)
|
||||
}
|
||||
|
||||
suspend fun await(mangaId: Long) {
|
||||
repository.resetHistoryByMangaId(mangaId)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package tachiyomi.domain.history.interactor
|
||||
|
||||
import tachiyomi.domain.history.model.HistoryUpdate
|
||||
import tachiyomi.domain.history.repository.HistoryRepository
|
||||
|
||||
class UpsertHistory(
|
||||
private val historyRepository: HistoryRepository,
|
||||
) {
|
||||
|
||||
suspend fun await(historyUpdate: HistoryUpdate) {
|
||||
historyRepository.upsertHistory(historyUpdate)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package tachiyomi.domain.updates.interactor
|
||||
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import tachiyomi.domain.updates.model.UpdatesWithRelations
|
||||
import tachiyomi.domain.updates.repository.UpdatesRepository
|
||||
import java.util.Calendar
|
||||
|
||||
class GetUpdates(
|
||||
private val repository: UpdatesRepository,
|
||||
) {
|
||||
|
||||
fun subscribe(calendar: Calendar): Flow<List<UpdatesWithRelations>> = subscribe(calendar.time.time)
|
||||
|
||||
fun subscribe(after: Long): Flow<List<UpdatesWithRelations>> {
|
||||
return repository.subscribeAll(after)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user