Revert "Revert history Compose/SQLDelight changes"

This reverts commit 96c894ce5b.
This commit is contained in:
arkon
2022-04-22 17:29:24 -04:00
parent 42eaaa497f
commit 2b79295240
89 changed files with 1814 additions and 996 deletions

View File

@@ -0,0 +1,12 @@
package eu.kanade.domain.history.interactor
import eu.kanade.domain.history.repository.HistoryRepository
class DeleteHistoryTable(
private val repository: HistoryRepository
) {
suspend fun await(): Boolean {
return repository.deleteAllHistory()
}
}

View File

@@ -0,0 +1,21 @@
package eu.kanade.domain.history.interactor
import androidx.paging.Pager
import androidx.paging.PagingConfig
import androidx.paging.PagingData
import eu.kanade.domain.history.model.HistoryWithRelations
import eu.kanade.domain.history.repository.HistoryRepository
import kotlinx.coroutines.flow.Flow
class GetHistory(
private val repository: HistoryRepository
) {
fun subscribe(query: String): Flow<PagingData<HistoryWithRelations>> {
return Pager(
PagingConfig(pageSize = 25)
) {
repository.getHistory(query)
}.flow
}
}

View File

@@ -0,0 +1,13 @@
package eu.kanade.domain.history.interactor
import eu.kanade.domain.chapter.model.Chapter
import eu.kanade.domain.history.repository.HistoryRepository
class GetNextChapterForManga(
private val repository: HistoryRepository
) {
suspend fun await(mangaId: Long, chapterId: Long): Chapter? {
return repository.getNextChapterForManga(mangaId, chapterId)
}
}

View File

@@ -0,0 +1,13 @@
package eu.kanade.domain.history.interactor
import eu.kanade.domain.history.model.HistoryWithRelations
import eu.kanade.domain.history.repository.HistoryRepository
class RemoveHistoryById(
private val repository: HistoryRepository
) {
suspend fun await(history: HistoryWithRelations) {
repository.resetHistory(history.id)
}
}

View File

@@ -0,0 +1,12 @@
package eu.kanade.domain.history.interactor
import eu.kanade.domain.history.repository.HistoryRepository
class RemoveHistoryByMangaId(
private val repository: HistoryRepository
) {
suspend fun await(mangaId: Long) {
repository.resetHistoryByMangaId(mangaId)
}
}

View File

@@ -0,0 +1,9 @@
package eu.kanade.domain.history.model
import java.util.*
data class History(
val id: Long?,
val chapterId: Long,
val readAt: Date?
)

View File

@@ -0,0 +1,13 @@
package eu.kanade.domain.history.model
import java.util.*
data class HistoryWithRelations(
val id: Long,
val chapterId: Long,
val mangaId: Long,
val title: String,
val thumbnailUrl: String,
val chapterNumber: Float,
val readAt: Date?
)

View File

@@ -0,0 +1,18 @@
package eu.kanade.domain.history.repository
import androidx.paging.PagingSource
import eu.kanade.domain.chapter.model.Chapter
import eu.kanade.domain.history.model.HistoryWithRelations
interface HistoryRepository {
fun getHistory(query: String): PagingSource<Long, HistoryWithRelations>
suspend fun getNextChapterForManga(mangaId: Long, chapterId: Long): Chapter?
suspend fun resetHistory(historyId: Long)
suspend fun resetHistoryByMangaId(mangaId: Long)
suspend fun deleteAllHistory(): Boolean
}