Use domain layer for almost all SY code

This commit is contained in:
Jobobby04
2022-07-04 18:37:30 -04:00
parent 141b0477e7
commit 6954c299b5
14 changed files with 99 additions and 41 deletions
@@ -32,10 +32,11 @@ class CategoryRepositoryImpl(
}
}
// SY -->
@Throws(DuplicateNameException::class)
override suspend fun insert(name: String, order: Long) {
override suspend fun insert(name: String, order: Long): Long {
if (checkDuplicateName(name)) throw DuplicateNameException(name)
handler.await {
return handler.awaitOne(true) {
categoriesQueries.insert(
name = name,
order = order,
@@ -44,8 +45,10 @@ class CategoryRepositoryImpl(
mangaOrder = emptyList(),
// SY <--
)
categoriesQueries.selectLastInsertedRowId()
}
}
// SY <--
@Throws(DuplicateNameException::class)
override suspend fun update(payload: CategoryUpdate) {
@@ -94,6 +94,10 @@ class ChapterRepositoryImpl(
}
// SY -->
override suspend fun getChapterByUrl(url: String): List<Chapter> {
return handler.awaitList { chaptersQueries.getChapterByUrl(url, chapterMapper) }
}
override suspend fun getMergedChapterByMangaId(mangaId: Long): List<Chapter> {
return handler.awaitList { chaptersQueries.getMergedChaptersByMangaId(mangaId, chapterMapper) }
}
@@ -5,6 +5,7 @@ import eu.kanade.data.DatabaseHandler
import eu.kanade.data.chapter.chapterMapper
import eu.kanade.data.manga.mangaMapper
import eu.kanade.domain.chapter.model.Chapter
import eu.kanade.domain.history.model.History
import eu.kanade.domain.history.model.HistoryUpdate
import eu.kanade.domain.history.model.HistoryWithRelations
import eu.kanade.domain.history.repository.HistoryRepository
@@ -109,4 +110,10 @@ class HistoryRepositoryImpl(
logcat(LogPriority.ERROR, throwable = e)
}
}
// SY -->
override suspend fun getByMangaId(mangaId: Long): List<History> {
return handler.awaitList { historyQueries.getHistoryByMangaId(mangaId, historyMapper) }
}
// SY <--
}