Changed data-mappers to use function format (#10045)
The lambda-format was really confusing to read and keep which anonymous data item was corresponding to which field. Now it's directly inspectable in the IDE (cherry picked from commit 15423bfc8476179dff20ed49e5aa92a5387061ff) # Conflicts: # data/src/main/java/tachiyomi/data/chapter/ChapterRepositoryImpl.kt # data/src/main/java/tachiyomi/data/manga/MangaMapper.kt # data/src/main/java/tachiyomi/data/manga/MangaRepositoryImpl.kt # data/src/main/java/tachiyomi/data/updates/UpdatesMapper.kt # data/src/main/java/tachiyomi/data/updates/UpdatesRepositoryImpl.kt
This commit is contained in:
parent
b131e1ca1f
commit
48ef273fb2
@ -58,7 +58,7 @@ import tachiyomi.core.preference.Preference
|
|||||||
import tachiyomi.core.preference.PreferenceStore
|
import tachiyomi.core.preference.PreferenceStore
|
||||||
import tachiyomi.core.util.system.logcat
|
import tachiyomi.core.util.system.logcat
|
||||||
import tachiyomi.data.DatabaseHandler
|
import tachiyomi.data.DatabaseHandler
|
||||||
import tachiyomi.data.manga.mangaMapper
|
import tachiyomi.data.manga.MangaMapper
|
||||||
import tachiyomi.domain.backup.service.BackupPreferences
|
import tachiyomi.domain.backup.service.BackupPreferences
|
||||||
import tachiyomi.domain.category.interactor.GetCategories
|
import tachiyomi.domain.category.interactor.GetCategories
|
||||||
import tachiyomi.domain.category.model.Category
|
import tachiyomi.domain.category.model.Category
|
||||||
@ -105,7 +105,7 @@ class BackupCreator(
|
|||||||
}
|
}
|
||||||
|
|
||||||
val databaseManga = getFavorites.await() /* SY --> */ + if (flags and BACKUP_READ_MANGA_MASK == BACKUP_READ_MANGA) {
|
val databaseManga = getFavorites.await() /* SY --> */ + if (flags and BACKUP_READ_MANGA_MASK == BACKUP_READ_MANGA) {
|
||||||
handler.awaitList { mangasQueries.getReadMangaNotInLibrary(mangaMapper) }
|
handler.awaitList { mangasQueries.getReadMangaNotInLibrary(MangaMapper::mapManga) }
|
||||||
} else {
|
} else {
|
||||||
emptyList()
|
emptyList()
|
||||||
} + getMergedManga.await() // SY <--
|
} + getMergedManga.await() // SY <--
|
||||||
|
@ -38,8 +38,8 @@ import tachiyomi.data.Manga_sync
|
|||||||
import tachiyomi.data.Mangas
|
import tachiyomi.data.Mangas
|
||||||
import tachiyomi.data.StringListAndColumnAdapter
|
import tachiyomi.data.StringListAndColumnAdapter
|
||||||
import tachiyomi.data.UpdateStrategyColumnAdapter
|
import tachiyomi.data.UpdateStrategyColumnAdapter
|
||||||
import tachiyomi.data.manga.mangaMapper
|
import tachiyomi.data.manga.MangaMapper
|
||||||
import tachiyomi.data.manga.mergedMangaReferenceMapper
|
import tachiyomi.data.manga.MergedMangaMapper
|
||||||
import tachiyomi.domain.category.interactor.GetCategories
|
import tachiyomi.domain.category.interactor.GetCategories
|
||||||
import tachiyomi.domain.chapter.model.Chapter
|
import tachiyomi.domain.chapter.model.Chapter
|
||||||
import tachiyomi.domain.history.model.HistoryUpdate
|
import tachiyomi.domain.history.model.HistoryUpdate
|
||||||
@ -689,7 +689,7 @@ class BackupRestorer(
|
|||||||
*/
|
*/
|
||||||
internal suspend fun restoreMergedMangaReferencesForManga(mergeMangaId: Long, backupMergedMangaReferences: List<BackupMergedMangaReference>) {
|
internal suspend fun restoreMergedMangaReferencesForManga(mergeMangaId: Long, backupMergedMangaReferences: List<BackupMergedMangaReference>) {
|
||||||
// Get merged manga references from file and from db
|
// Get merged manga references from file and from db
|
||||||
val dbMergedMangaReferences = handler.awaitList { mergedQueries.selectAll(mergedMangaReferenceMapper) }
|
val dbMergedMangaReferences = handler.awaitList { mergedQueries.selectAll(MergedMangaMapper::map) }
|
||||||
|
|
||||||
// Iterate over them
|
// Iterate over them
|
||||||
backupMergedMangaReferences.forEach { backupMergedMangaReference ->
|
backupMergedMangaReferences.forEach { backupMergedMangaReference ->
|
||||||
@ -697,7 +697,7 @@ class BackupRestorer(
|
|||||||
// Store the inserted id in the backupMergedMangaReference
|
// Store the inserted id in the backupMergedMangaReference
|
||||||
if (dbMergedMangaReferences.none { backupMergedMangaReference.mergeUrl == it.mergeUrl && backupMergedMangaReference.mangaUrl == it.mangaUrl }) {
|
if (dbMergedMangaReferences.none { backupMergedMangaReference.mergeUrl == it.mergeUrl && backupMergedMangaReference.mangaUrl == it.mangaUrl }) {
|
||||||
// Let the db assign the id
|
// Let the db assign the id
|
||||||
val mergedManga = handler.awaitOneOrNull { mangasQueries.getMangaByUrlAndSource(backupMergedMangaReference.mangaUrl, backupMergedMangaReference.mangaSourceId, mangaMapper) } ?: return@forEach
|
val mergedManga = handler.awaitOneOrNull { mangasQueries.getMangaByUrlAndSource(backupMergedMangaReference.mangaUrl, backupMergedMangaReference.mangaSourceId, MangaMapper::mapManga) } ?: return@forEach
|
||||||
backupMergedMangaReference.getMergedMangaReference().run {
|
backupMergedMangaReference.getMergedMangaReference().run {
|
||||||
handler.await {
|
handler.await {
|
||||||
mergedQueries.insert(
|
mergedQueries.insert(
|
||||||
|
@ -48,8 +48,8 @@ import tachiyomi.core.preference.getEnum
|
|||||||
import tachiyomi.core.preference.minusAssign
|
import tachiyomi.core.preference.minusAssign
|
||||||
import tachiyomi.core.util.system.logcat
|
import tachiyomi.core.util.system.logcat
|
||||||
import tachiyomi.data.DatabaseHandler
|
import tachiyomi.data.DatabaseHandler
|
||||||
import tachiyomi.data.category.categoryMapper
|
import tachiyomi.data.category.CategoryMapper
|
||||||
import tachiyomi.data.chapter.chapterMapper
|
import tachiyomi.data.chapter.ChapterMapper
|
||||||
import tachiyomi.domain.backup.service.BackupPreferences
|
import tachiyomi.domain.backup.service.BackupPreferences
|
||||||
import tachiyomi.domain.chapter.interactor.DeleteChapters
|
import tachiyomi.domain.chapter.interactor.DeleteChapters
|
||||||
import tachiyomi.domain.chapter.interactor.UpdateChapter
|
import tachiyomi.domain.chapter.interactor.UpdateChapter
|
||||||
@ -184,8 +184,8 @@ object EXHMigrations {
|
|||||||
}
|
}
|
||||||
|
|
||||||
val loadedMangaList = mangaConfigs.map { it.second.children }.flatten().mapNotNull { it.load() }.distinct()
|
val loadedMangaList = mangaConfigs.map { it.second.children }.flatten().mapNotNull { it.load() }.distinct()
|
||||||
val chapters = runBlocking { handler.awaitList { ehQueries.getChaptersByMangaIds(mergedMangas.map { it.id }, chapterMapper) } }
|
val chapters = runBlocking { handler.awaitList { ehQueries.getChaptersByMangaIds(mergedMangas.map { it.id }, ChapterMapper::mapChapter) } }
|
||||||
val mergedMangaChapters = runBlocking { handler.awaitList { ehQueries.getChaptersByMangaIds(loadedMangaList.map { it.manga.id }, chapterMapper) } }
|
val mergedMangaChapters = runBlocking { handler.awaitList { ehQueries.getChaptersByMangaIds(loadedMangaList.map { it.manga.id }, ChapterMapper::mapChapter) } }
|
||||||
|
|
||||||
val mergedMangaChaptersMatched = mergedMangaChapters.mapNotNull { chapter -> loadedMangaList.firstOrNull { it.manga.id == chapter.id }?.let { it to chapter } }
|
val mergedMangaChaptersMatched = mergedMangaChapters.mapNotNull { chapter -> loadedMangaList.firstOrNull { it.manga.id == chapter.id }?.let { it to chapter } }
|
||||||
val parsedChapters = chapters.filter { it.read || it.lastPageRead != 0L }.mapNotNull { chapter -> readUrlConfig(chapter.url)?.let { chapter to it } }
|
val parsedChapters = chapters.filter { it.read || it.lastPageRead != 0L }.mapNotNull { chapter -> readUrlConfig(chapter.url)?.let { chapter to it } }
|
||||||
@ -430,7 +430,7 @@ object EXHMigrations {
|
|||||||
}
|
}
|
||||||
runBlocking {
|
runBlocking {
|
||||||
handler.await(true) {
|
handler.await(true) {
|
||||||
categoriesQueries.getCategories(categoryMapper).executeAsList()
|
categoriesQueries.getCategories(CategoryMapper::mapCategory).executeAsList()
|
||||||
.filter { (it.flags and 0b00111100L) == 0b00100000L }
|
.filter { (it.flags and 0b00111100L) == 0b00100000L }
|
||||||
.forEach {
|
.forEach {
|
||||||
categoriesQueries.update(
|
categoriesQueries.update(
|
||||||
|
@ -2,11 +2,18 @@ package tachiyomi.data.category
|
|||||||
|
|
||||||
import tachiyomi.domain.category.model.Category
|
import tachiyomi.domain.category.model.Category
|
||||||
|
|
||||||
val categoryMapper: (Long, String, Long, Long) -> Category = { id, name, order, flags ->
|
object CategoryMapper {
|
||||||
Category(
|
fun mapCategory(
|
||||||
|
id: Long,
|
||||||
|
name: String,
|
||||||
|
order: Long,
|
||||||
|
flags: Long,
|
||||||
|
): Category {
|
||||||
|
return Category(
|
||||||
id = id,
|
id = id,
|
||||||
name = name,
|
name = name,
|
||||||
order = order,
|
order = order,
|
||||||
flags = flags,
|
flags = flags,
|
||||||
)
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,26 +12,26 @@ class CategoryRepositoryImpl(
|
|||||||
) : CategoryRepository {
|
) : CategoryRepository {
|
||||||
|
|
||||||
override suspend fun get(id: Long): Category? {
|
override suspend fun get(id: Long): Category? {
|
||||||
return handler.awaitOneOrNull { categoriesQueries.getCategory(id, categoryMapper) }
|
return handler.awaitOneOrNull { categoriesQueries.getCategory(id, CategoryMapper::mapCategory) }
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun getAll(): List<Category> {
|
override suspend fun getAll(): List<Category> {
|
||||||
return handler.awaitList { categoriesQueries.getCategories(categoryMapper) }
|
return handler.awaitList { categoriesQueries.getCategories(CategoryMapper::mapCategory) }
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getAllAsFlow(): Flow<List<Category>> {
|
override fun getAllAsFlow(): Flow<List<Category>> {
|
||||||
return handler.subscribeToList { categoriesQueries.getCategories(categoryMapper) }
|
return handler.subscribeToList { categoriesQueries.getCategories(CategoryMapper::mapCategory) }
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun getCategoriesByMangaId(mangaId: Long): List<Category> {
|
override suspend fun getCategoriesByMangaId(mangaId: Long): List<Category> {
|
||||||
return handler.awaitList {
|
return handler.awaitList {
|
||||||
categoriesQueries.getCategoriesByMangaId(mangaId, categoryMapper)
|
categoriesQueries.getCategoriesByMangaId(mangaId, CategoryMapper::mapCategory)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getCategoriesByMangaIdAsFlow(mangaId: Long): Flow<List<Category>> {
|
override fun getCategoriesByMangaIdAsFlow(mangaId: Long): Flow<List<Category>> {
|
||||||
return handler.subscribeToList {
|
return handler.subscribeToList {
|
||||||
categoriesQueries.getCategoriesByMangaId(mangaId, categoryMapper)
|
categoriesQueries.getCategoriesByMangaId(mangaId, CategoryMapper::mapCategory)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,23 +2,22 @@ package tachiyomi.data.chapter
|
|||||||
|
|
||||||
import tachiyomi.domain.chapter.model.Chapter
|
import tachiyomi.domain.chapter.model.Chapter
|
||||||
|
|
||||||
val chapterMapper: (
|
object ChapterMapper {
|
||||||
Long,
|
fun mapChapter(
|
||||||
Long,
|
id: Long,
|
||||||
String,
|
mangaId: Long,
|
||||||
String,
|
url: String,
|
||||||
String?,
|
name: String,
|
||||||
Boolean,
|
scanlator: String?,
|
||||||
Boolean,
|
read: Boolean,
|
||||||
Long,
|
bookmark: Boolean,
|
||||||
Double,
|
lastPageRead: Long,
|
||||||
Long,
|
chapterNumber: Double,
|
||||||
Long,
|
sourceOrder: Long,
|
||||||
Long,
|
dateFetch: Long,
|
||||||
Long,
|
dateUpload: Long,
|
||||||
) -> Chapter =
|
lastModifiedAt: Long,
|
||||||
{ id, mangaId, url, name, scanlator, read, bookmark, lastPageRead, chapterNumber, sourceOrder, dateFetch, dateUpload, lastModifiedAt ->
|
): Chapter = Chapter(
|
||||||
Chapter(
|
|
||||||
id = id,
|
id = id,
|
||||||
mangaId = mangaId,
|
mangaId = mangaId,
|
||||||
read = read,
|
read = read,
|
||||||
@ -33,4 +32,4 @@ val chapterMapper: (
|
|||||||
scanlator = scanlator,
|
scanlator = scanlator,
|
||||||
lastModifiedAt = lastModifiedAt,
|
lastModifiedAt = lastModifiedAt,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -77,27 +77,27 @@ class ChapterRepositoryImpl(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun getChapterByMangaId(mangaId: Long): List<Chapter> {
|
override suspend fun getChapterByMangaId(mangaId: Long): List<Chapter> {
|
||||||
return handler.awaitList { chaptersQueries.getChaptersByMangaId(mangaId, chapterMapper) }
|
return handler.awaitList { chaptersQueries.getChaptersByMangaId(mangaId, ChapterMapper::mapChapter) }
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun getBookmarkedChaptersByMangaId(mangaId: Long): List<Chapter> {
|
override suspend fun getBookmarkedChaptersByMangaId(mangaId: Long): List<Chapter> {
|
||||||
return handler.awaitList {
|
return handler.awaitList {
|
||||||
chaptersQueries.getBookmarkedChaptersByMangaId(
|
chaptersQueries.getBookmarkedChaptersByMangaId(
|
||||||
mangaId,
|
mangaId,
|
||||||
chapterMapper,
|
ChapterMapper::mapChapter,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun getChapterById(id: Long): Chapter? {
|
override suspend fun getChapterById(id: Long): Chapter? {
|
||||||
return handler.awaitOneOrNull { chaptersQueries.getChapterById(id, chapterMapper) }
|
return handler.awaitOneOrNull { chaptersQueries.getChapterById(id, ChapterMapper::mapChapter) }
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun getChapterByMangaIdAsFlow(mangaId: Long): Flow<List<Chapter>> {
|
override suspend fun getChapterByMangaIdAsFlow(mangaId: Long): Flow<List<Chapter>> {
|
||||||
return handler.subscribeToList {
|
return handler.subscribeToList {
|
||||||
chaptersQueries.getChaptersByMangaId(
|
chaptersQueries.getChaptersByMangaId(
|
||||||
mangaId,
|
mangaId,
|
||||||
chapterMapper,
|
ChapterMapper::mapChapter,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -107,22 +107,22 @@ class ChapterRepositoryImpl(
|
|||||||
chaptersQueries.getChapterByUrlAndMangaId(
|
chaptersQueries.getChapterByUrlAndMangaId(
|
||||||
url,
|
url,
|
||||||
mangaId,
|
mangaId,
|
||||||
chapterMapper,
|
ChapterMapper::mapChapter,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// SY -->
|
// SY -->
|
||||||
override suspend fun getChapterByUrl(url: String): List<Chapter> {
|
override suspend fun getChapterByUrl(url: String): List<Chapter> {
|
||||||
return handler.awaitList { chaptersQueries.getChapterByUrl(url, chapterMapper) }
|
return handler.awaitList { chaptersQueries.getChapterByUrl(url, ChapterMapper::mapChapter) }
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun getMergedChapterByMangaId(mangaId: Long): List<Chapter> {
|
override suspend fun getMergedChapterByMangaId(mangaId: Long): List<Chapter> {
|
||||||
return handler.awaitList { chaptersQueries.getMergedChaptersByMangaId(mangaId, chapterMapper) }
|
return handler.awaitList { chaptersQueries.getMergedChaptersByMangaId(mangaId, ChapterMapper::mapChapter) }
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun getMergedChapterByMangaIdAsFlow(mangaId: Long): Flow<List<Chapter>> {
|
override suspend fun getMergedChapterByMangaIdAsFlow(mangaId: Long): Flow<List<Chapter>> {
|
||||||
return handler.subscribeToList { chaptersQueries.getMergedChaptersByMangaId(mangaId, chapterMapper) }
|
return handler.subscribeToList { chaptersQueries.getMergedChaptersByMangaId(mangaId, ChapterMapper::mapChapter) }
|
||||||
}
|
}
|
||||||
// SY <--
|
// SY <--
|
||||||
}
|
}
|
||||||
|
@ -5,30 +5,32 @@ import tachiyomi.domain.history.model.HistoryWithRelations
|
|||||||
import tachiyomi.domain.manga.model.MangaCover
|
import tachiyomi.domain.manga.model.MangaCover
|
||||||
import java.util.Date
|
import java.util.Date
|
||||||
|
|
||||||
val historyMapper: (Long, Long, Date?, Long) -> History = { id, chapterId, readAt, readDuration ->
|
object HistoryMapper {
|
||||||
History(
|
fun mapHistory(
|
||||||
|
id: Long,
|
||||||
|
chapterId: Long,
|
||||||
|
readAt: Date?,
|
||||||
|
readDuration: Long,
|
||||||
|
): History = History(
|
||||||
id = id,
|
id = id,
|
||||||
chapterId = chapterId,
|
chapterId = chapterId,
|
||||||
readAt = readAt,
|
readAt = readAt,
|
||||||
readDuration = readDuration,
|
readDuration = readDuration,
|
||||||
)
|
)
|
||||||
}
|
|
||||||
|
|
||||||
val historyWithRelationsMapper: (
|
fun mapHistoryWithRelations(
|
||||||
Long,
|
historyId: Long,
|
||||||
Long,
|
mangaId: Long,
|
||||||
Long,
|
chapterId: Long,
|
||||||
String,
|
title: String,
|
||||||
String?,
|
thumbnailUrl: String?,
|
||||||
Long,
|
sourceId: Long,
|
||||||
Boolean,
|
isFavorite: Boolean,
|
||||||
Long,
|
coverLastModified: Long,
|
||||||
Double,
|
chapterNumber: Double,
|
||||||
Date?,
|
readAt: Date?,
|
||||||
Long,
|
readDuration: Long,
|
||||||
) -> HistoryWithRelations = {
|
): HistoryWithRelations = HistoryWithRelations(
|
||||||
historyId, mangaId, chapterId, title, thumbnailUrl, sourceId, isFavorite, coverLastModified, chapterNumber, readAt, readDuration ->
|
|
||||||
HistoryWithRelations(
|
|
||||||
id = historyId,
|
id = historyId,
|
||||||
chapterId = chapterId,
|
chapterId = chapterId,
|
||||||
mangaId = mangaId,
|
mangaId = mangaId,
|
||||||
|
@ -15,13 +15,13 @@ class HistoryRepositoryImpl(
|
|||||||
|
|
||||||
override fun getHistory(query: String): Flow<List<HistoryWithRelations>> {
|
override fun getHistory(query: String): Flow<List<HistoryWithRelations>> {
|
||||||
return handler.subscribeToList {
|
return handler.subscribeToList {
|
||||||
historyViewQueries.history(query, historyWithRelationsMapper)
|
historyViewQueries.history(query, HistoryMapper::mapHistoryWithRelations)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun getLastHistory(): HistoryWithRelations? {
|
override suspend fun getLastHistory(): HistoryWithRelations? {
|
||||||
return handler.awaitOneOrNull {
|
return handler.awaitOneOrNull {
|
||||||
historyViewQueries.getLatestHistory(historyWithRelationsMapper)
|
historyViewQueries.getLatestHistory(HistoryMapper::mapHistoryWithRelations)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -30,7 +30,7 @@ class HistoryRepositoryImpl(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun getHistoryByMangaId(mangaId: Long): List<History> {
|
override suspend fun getHistoryByMangaId(mangaId: Long): List<History> {
|
||||||
return handler.awaitList { historyQueries.getHistoryByMangaId(mangaId, historyMapper) }
|
return handler.awaitList { historyQueries.getHistoryByMangaId(mangaId, HistoryMapper::mapHistory) }
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun resetHistory(historyId: Long) {
|
override suspend fun resetHistory(historyId: Long) {
|
||||||
@ -91,7 +91,7 @@ class HistoryRepositoryImpl(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun getByMangaId(mangaId: Long): List<History> {
|
override suspend fun getByMangaId(mangaId: Long): List<History> {
|
||||||
return handler.awaitList { historyQueries.getHistoryByMangaId(mangaId, historyMapper) }
|
return handler.awaitList { historyQueries.getHistoryByMangaId(mangaId, HistoryMapper::mapHistory) }
|
||||||
}
|
}
|
||||||
// SY <--
|
// SY <--
|
||||||
}
|
}
|
||||||
|
@ -1,15 +0,0 @@
|
|||||||
package tachiyomi.data.manga
|
|
||||||
|
|
||||||
import tachiyomi.domain.manga.model.FavoriteEntry
|
|
||||||
|
|
||||||
val favoriteEntryMapper: (String, String, String, Long, String?, String?) -> FavoriteEntry =
|
|
||||||
{ gid, token, title, category, otherGid, otherToken ->
|
|
||||||
FavoriteEntry(
|
|
||||||
gid = gid,
|
|
||||||
token = token,
|
|
||||||
title = title,
|
|
||||||
category = category.toInt(),
|
|
||||||
otherGid = otherGid,
|
|
||||||
otherToken = otherToken,
|
|
||||||
)
|
|
||||||
}
|
|
@ -28,7 +28,7 @@ class FavoritesEntryRepositoryImpl(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun selectAll(): List<FavoriteEntry> {
|
override suspend fun selectAll(): List<FavoriteEntry> {
|
||||||
return handler.awaitList { eh_favoritesQueries.selectAll(favoriteEntryMapper) }
|
return handler.awaitList { eh_favoritesQueries.selectAll(::mapFavoriteEntry) }
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun addAlternative(favoriteEntryAlternative: FavoriteEntryAlternative) {
|
override suspend fun addAlternative(favoriteEntryAlternative: FavoriteEntryAlternative) {
|
||||||
@ -45,4 +45,22 @@ class FavoritesEntryRepositoryImpl(
|
|||||||
logcat(LogPriority.INFO, e)
|
logcat(LogPriority.INFO, e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun mapFavoriteEntry(
|
||||||
|
gid: String,
|
||||||
|
token: String,
|
||||||
|
title: String,
|
||||||
|
category: Long,
|
||||||
|
otherGid: String?,
|
||||||
|
otherToken: String?,
|
||||||
|
): FavoriteEntry {
|
||||||
|
return FavoriteEntry(
|
||||||
|
gid = gid,
|
||||||
|
token = token,
|
||||||
|
title = title,
|
||||||
|
category = category.toInt(),
|
||||||
|
otherGid = otherGid,
|
||||||
|
otherToken = otherToken,
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,9 +5,33 @@ import tachiyomi.domain.library.model.LibraryManga
|
|||||||
import tachiyomi.domain.manga.model.Manga
|
import tachiyomi.domain.manga.model.Manga
|
||||||
import tachiyomi.view.LibraryView
|
import tachiyomi.view.LibraryView
|
||||||
|
|
||||||
val mangaMapper: (Long, Long, String, String?, String?, String?, List<String>?, String, Long, String?, Boolean, Long?, Long?, Boolean, Long, Long, Long, Long, List<String>?, UpdateStrategy, Long, Long, Long?) -> Manga =
|
|
||||||
{ id, source, url, artist, author, description, genre, title, status, thumbnailUrl, favorite, lastUpdate, nextUpdate, initialized, viewerFlags, chapterFlags, coverLastModified, dateAdded, filteredScanlators, updateStrategy, calculateInterval, lastModifiedAt, favoriteModifiedAt ->
|
object MangaMapper {
|
||||||
Manga(
|
fun mapManga(
|
||||||
|
id: Long,
|
||||||
|
source: Long,
|
||||||
|
url: String,
|
||||||
|
artist: String?,
|
||||||
|
author: String?,
|
||||||
|
description: String?,
|
||||||
|
genre: List<String>?,
|
||||||
|
title: String,
|
||||||
|
status: Long,
|
||||||
|
thumbnailUrl: String?,
|
||||||
|
favorite: Boolean,
|
||||||
|
lastUpdate: Long?,
|
||||||
|
nextUpdate: Long?,
|
||||||
|
initialized: Boolean,
|
||||||
|
viewerFlags: Long,
|
||||||
|
chapterFlags: Long,
|
||||||
|
coverLastModified: Long,
|
||||||
|
dateAdded: Long,
|
||||||
|
filteredScanlators: List<String>?,
|
||||||
|
updateStrategy: UpdateStrategy,
|
||||||
|
calculateInterval: Long,
|
||||||
|
lastModifiedAt: Long,
|
||||||
|
favoriteModifiedAt: Long?,
|
||||||
|
): Manga = Manga(
|
||||||
id = id,
|
id = id,
|
||||||
source = source,
|
source = source,
|
||||||
favorite = favorite,
|
favorite = favorite,
|
||||||
@ -36,12 +60,40 @@ val mangaMapper: (Long, Long, String, String?, String?, String?, List<String>?,
|
|||||||
lastModifiedAt = lastModifiedAt,
|
lastModifiedAt = lastModifiedAt,
|
||||||
favoriteModifiedAt = favoriteModifiedAt,
|
favoriteModifiedAt = favoriteModifiedAt,
|
||||||
)
|
)
|
||||||
}
|
|
||||||
|
|
||||||
val libraryManga: (Long, Long, String, String?, String?, String?, List<String>?, String, Long, String?, Boolean, Long?, Long?, Boolean, Long, Long, Long, Long, List<String>?, UpdateStrategy, Long, Long, Long?, Long, Double, Long, Long, Long, Double, Long) -> LibraryManga =
|
fun mapLibraryManga(
|
||||||
{ id, source, url, artist, author, description, genre, title, status, thumbnailUrl, favorite, lastUpdate, nextUpdate, initialized, viewerFlags, chapterFlags, coverLastModified, dateAdded, filteredScanlators, updateStrategy, calculateInterval, lastModifiedAt, favoriteModifiedAt, totalCount, readCount, latestUpload, chapterFetchedAt, lastRead, bookmarkCount, category ->
|
id: Long,
|
||||||
LibraryManga(
|
source: Long,
|
||||||
manga = mangaMapper(
|
url: String,
|
||||||
|
artist: String?,
|
||||||
|
author: String?,
|
||||||
|
description: String?,
|
||||||
|
genre: List<String>?,
|
||||||
|
title: String,
|
||||||
|
status: Long,
|
||||||
|
thumbnailUrl: String?,
|
||||||
|
favorite: Boolean,
|
||||||
|
lastUpdate: Long?,
|
||||||
|
nextUpdate: Long?,
|
||||||
|
initialized: Boolean,
|
||||||
|
viewerFlags: Long,
|
||||||
|
chapterFlags: Long,
|
||||||
|
coverLastModified: Long,
|
||||||
|
dateAdded: Long,
|
||||||
|
filteredScanlators: List<String>?,
|
||||||
|
updateStrategy: UpdateStrategy,
|
||||||
|
calculateInterval: Long,
|
||||||
|
lastModifiedAt: Long,
|
||||||
|
favoriteModifiedAt: Long?,
|
||||||
|
totalCount: Long,
|
||||||
|
readCount: Double,
|
||||||
|
latestUpload: Long,
|
||||||
|
chapterFetchedAt: Long,
|
||||||
|
lastRead: Long,
|
||||||
|
bookmarkCount: Double,
|
||||||
|
category: Long,
|
||||||
|
): LibraryManga = LibraryManga(
|
||||||
|
manga = mapManga(
|
||||||
id,
|
id,
|
||||||
source,
|
source,
|
||||||
url,
|
url,
|
||||||
@ -76,41 +128,41 @@ val libraryManga: (Long, Long, String, String?, String?, String?, List<String>?,
|
|||||||
chapterFetchedAt = chapterFetchedAt,
|
chapterFetchedAt = chapterFetchedAt,
|
||||||
lastRead = lastRead,
|
lastRead = lastRead,
|
||||||
)
|
)
|
||||||
}
|
|
||||||
|
|
||||||
val libraryViewMapper: (LibraryView) -> LibraryManga = {
|
fun mapLibraryView(libraryView: LibraryView): LibraryManga {
|
||||||
LibraryManga(
|
return LibraryManga(
|
||||||
manga = Manga(
|
manga = Manga(
|
||||||
id = it._id,
|
id = libraryView._id,
|
||||||
source = it.source,
|
source = libraryView.source,
|
||||||
favorite = it.favorite,
|
favorite = libraryView.favorite,
|
||||||
lastUpdate = it.last_update ?: 0,
|
lastUpdate = libraryView.last_update ?: 0,
|
||||||
nextUpdate = it.next_update ?: 0,
|
nextUpdate = libraryView.next_update ?: 0,
|
||||||
dateAdded = it.date_added,
|
dateAdded = libraryView.date_added,
|
||||||
viewerFlags = it.viewer,
|
viewerFlags = libraryView.viewer,
|
||||||
chapterFlags = it.chapter_flags,
|
chapterFlags = libraryView.chapter_flags,
|
||||||
coverLastModified = it.cover_last_modified,
|
coverLastModified = libraryView.cover_last_modified,
|
||||||
url = it.url,
|
url = libraryView.url,
|
||||||
ogTitle = it.title,
|
ogTitle = libraryView.title,
|
||||||
ogArtist = it.artist,
|
ogArtist = libraryView.artist,
|
||||||
ogAuthor = it.author,
|
ogAuthor = libraryView.author,
|
||||||
ogDescription = it.description,
|
ogDescription = libraryView.description,
|
||||||
ogGenre = it.genre,
|
ogGenre = libraryView.genre,
|
||||||
ogStatus = it.status,
|
ogStatus = libraryView.status,
|
||||||
thumbnailUrl = it.thumbnail_url,
|
thumbnailUrl = libraryView.thumbnail_url,
|
||||||
updateStrategy = it.update_strategy,
|
updateStrategy = libraryView.update_strategy,
|
||||||
initialized = it.initialized,
|
initialized = libraryView.initialized,
|
||||||
filteredScanlators = it.filtered_scanlators,
|
filteredScanlators = libraryView.filtered_scanlators,
|
||||||
fetchInterval = it.calculate_interval.toInt(),
|
fetchInterval = libraryView.calculate_interval.toInt(),
|
||||||
lastModifiedAt = it.last_modified_at,
|
lastModifiedAt = libraryView.last_modified_at,
|
||||||
favoriteModifiedAt = it.favorite_modified_at,
|
favoriteModifiedAt = libraryView.favorite_modified_at,
|
||||||
),
|
),
|
||||||
category = it.category,
|
category = libraryView.category,
|
||||||
totalChapters = it.totalCount,
|
totalChapters = libraryView.totalCount,
|
||||||
readCount = it.readCount.toLong(),
|
readCount = libraryView.readCount.toLong(),
|
||||||
bookmarkCount = it.bookmarkCount.toLong(),
|
bookmarkCount = libraryView.bookmarkCount.toLong(),
|
||||||
latestUpload = it.latestUpload,
|
latestUpload = libraryView.latestUpload,
|
||||||
chapterFetchedAt = it.chapterFetchedAt,
|
chapterFetchedAt = libraryView.chapterFetchedAt,
|
||||||
lastRead = it.lastRead,
|
lastRead = libraryView.lastRead,
|
||||||
)
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,27 +14,27 @@ class MangaMergeRepositoryImpl(
|
|||||||
) : MangaMergeRepository {
|
) : MangaMergeRepository {
|
||||||
|
|
||||||
override suspend fun getMergedManga(): List<Manga> {
|
override suspend fun getMergedManga(): List<Manga> {
|
||||||
return handler.awaitList { mergedQueries.selectAllMergedMangas(mangaMapper) }
|
return handler.awaitList { mergedQueries.selectAllMergedMangas(MangaMapper::mapManga) }
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun subscribeMergedManga(): Flow<List<Manga>> {
|
override suspend fun subscribeMergedManga(): Flow<List<Manga>> {
|
||||||
return handler.subscribeToList { mergedQueries.selectAllMergedMangas(mangaMapper) }
|
return handler.subscribeToList { mergedQueries.selectAllMergedMangas(MangaMapper::mapManga) }
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun getMergedMangaById(id: Long): List<Manga> {
|
override suspend fun getMergedMangaById(id: Long): List<Manga> {
|
||||||
return handler.awaitList { mergedQueries.selectMergedMangasById(id, mangaMapper) }
|
return handler.awaitList { mergedQueries.selectMergedMangasById(id, MangaMapper::mapManga) }
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun subscribeMergedMangaById(id: Long): Flow<List<Manga>> {
|
override suspend fun subscribeMergedMangaById(id: Long): Flow<List<Manga>> {
|
||||||
return handler.subscribeToList { mergedQueries.selectMergedMangasById(id, mangaMapper) }
|
return handler.subscribeToList { mergedQueries.selectMergedMangasById(id, MangaMapper::mapManga) }
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun getReferencesById(id: Long): List<MergedMangaReference> {
|
override suspend fun getReferencesById(id: Long): List<MergedMangaReference> {
|
||||||
return handler.awaitList { mergedQueries.selectByMergeId(id, mergedMangaReferenceMapper) }
|
return handler.awaitList { mergedQueries.selectByMergeId(id, MergedMangaMapper::map) }
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun subscribeReferencesById(id: Long): Flow<List<MergedMangaReference>> {
|
override suspend fun subscribeReferencesById(id: Long): Flow<List<MergedMangaReference>> {
|
||||||
return handler.subscribeToList { mergedQueries.selectByMergeId(id, mergedMangaReferenceMapper) }
|
return handler.subscribeToList { mergedQueries.selectByMergeId(id, MergedMangaMapper::map) }
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun updateSettings(update: MergeMangaSettingsUpdate): Boolean {
|
override suspend fun updateSettings(update: MergeMangaSettingsUpdate): Boolean {
|
||||||
@ -122,6 +122,6 @@ class MangaMergeRepositoryImpl(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun getMergeMangaForDownloading(mergeId: Long): List<Manga> {
|
override suspend fun getMergeMangaForDownloading(mergeId: Long): List<Manga> {
|
||||||
return handler.awaitList { mergedQueries.selectMergedMangasForDownloadingById(mergeId, mangaMapper) }
|
return handler.awaitList { mergedQueries.selectMergedMangasForDownloadingById(mergeId, MangaMapper::mapManga) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,27 +16,27 @@ class MangaMetadataRepositoryImpl(
|
|||||||
) : MangaMetadataRepository {
|
) : MangaMetadataRepository {
|
||||||
|
|
||||||
override suspend fun getMetadataById(id: Long): SearchMetadata? {
|
override suspend fun getMetadataById(id: Long): SearchMetadata? {
|
||||||
return handler.awaitOneOrNull { search_metadataQueries.selectByMangaId(id, searchMetadataMapper) }
|
return handler.awaitOneOrNull { search_metadataQueries.selectByMangaId(id, ::searchMetadataMapper) }
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun subscribeMetadataById(id: Long): Flow<SearchMetadata?> {
|
override fun subscribeMetadataById(id: Long): Flow<SearchMetadata?> {
|
||||||
return handler.subscribeToOneOrNull { search_metadataQueries.selectByMangaId(id, searchMetadataMapper) }
|
return handler.subscribeToOneOrNull { search_metadataQueries.selectByMangaId(id, ::searchMetadataMapper) }
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun getTagsById(id: Long): List<SearchTag> {
|
override suspend fun getTagsById(id: Long): List<SearchTag> {
|
||||||
return handler.awaitList { search_tagsQueries.selectByMangaId(id, searchTagMapper) }
|
return handler.awaitList { search_tagsQueries.selectByMangaId(id, ::searchTagMapper) }
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun subscribeTagsById(id: Long): Flow<List<SearchTag>> {
|
override fun subscribeTagsById(id: Long): Flow<List<SearchTag>> {
|
||||||
return handler.subscribeToList { search_tagsQueries.selectByMangaId(id, searchTagMapper) }
|
return handler.subscribeToList { search_tagsQueries.selectByMangaId(id, ::searchTagMapper) }
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun getTitlesById(id: Long): List<SearchTitle> {
|
override suspend fun getTitlesById(id: Long): List<SearchTitle> {
|
||||||
return handler.awaitList { search_titlesQueries.selectByMangaId(id, searchTitleMapper) }
|
return handler.awaitList { search_titlesQueries.selectByMangaId(id, ::searchTitleMapper) }
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun subscribeTitlesById(id: Long): Flow<List<SearchTitle>> {
|
override fun subscribeTitlesById(id: Long): Flow<List<SearchTitle>> {
|
||||||
return handler.subscribeToList { search_titlesQueries.selectByMangaId(id, searchTitleMapper) }
|
return handler.subscribeToList { search_titlesQueries.selectByMangaId(id, ::searchTitleMapper) }
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun insertFlatMetadata(flatMetadata: FlatMetadata) {
|
override suspend fun insertFlatMetadata(flatMetadata: FlatMetadata) {
|
||||||
@ -58,7 +58,7 @@ class MangaMetadataRepositoryImpl(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun getExhFavoriteMangaWithMetadata(): List<Manga> {
|
override suspend fun getExhFavoriteMangaWithMetadata(): List<Manga> {
|
||||||
return handler.awaitList { mangasQueries.getEhMangaWithMetadata(EH_SOURCE_ID, EXH_SOURCE_ID, mangaMapper) }
|
return handler.awaitList { mangasQueries.getEhMangaWithMetadata(EH_SOURCE_ID, EXH_SOURCE_ID, MangaMapper::mapManga) }
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun getIdsOfFavoriteMangaWithMetadata(): List<Long> {
|
override suspend fun getIdsOfFavoriteMangaWithMetadata(): List<Long> {
|
||||||
@ -66,6 +66,52 @@ class MangaMetadataRepositoryImpl(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun getSearchMetadata(): List<SearchMetadata> {
|
override suspend fun getSearchMetadata(): List<SearchMetadata> {
|
||||||
return handler.awaitList { search_metadataQueries.selectAll(searchMetadataMapper) }
|
return handler.awaitList { search_metadataQueries.selectAll(::searchMetadataMapper) }
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun searchMetadataMapper(
|
||||||
|
mangaId: Long,
|
||||||
|
uploader: String?,
|
||||||
|
extra: String,
|
||||||
|
indexedExtra: String?,
|
||||||
|
extraVersion: Long
|
||||||
|
): SearchMetadata {
|
||||||
|
return SearchMetadata(
|
||||||
|
mangaId = mangaId,
|
||||||
|
uploader = uploader,
|
||||||
|
extra = extra,
|
||||||
|
indexedExtra = indexedExtra,
|
||||||
|
extraVersion = extraVersion.toInt(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun searchTitleMapper(
|
||||||
|
mangaId: Long,
|
||||||
|
id: Long?,
|
||||||
|
title: String,
|
||||||
|
type: Long,
|
||||||
|
): SearchTitle {
|
||||||
|
return SearchTitle(
|
||||||
|
mangaId = mangaId,
|
||||||
|
id = id,
|
||||||
|
title = title,
|
||||||
|
type = type.toInt(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun searchTagMapper(
|
||||||
|
mangaId: Long,
|
||||||
|
id: Long?,
|
||||||
|
namespace: String?,
|
||||||
|
name: String,
|
||||||
|
type: Long,
|
||||||
|
): SearchTag {
|
||||||
|
return SearchTag(
|
||||||
|
mangaId = mangaId,
|
||||||
|
id = id,
|
||||||
|
namespace = namespace,
|
||||||
|
name = name,
|
||||||
|
type = type.toInt(),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,11 +19,11 @@ class MangaRepositoryImpl(
|
|||||||
) : MangaRepository {
|
) : MangaRepository {
|
||||||
|
|
||||||
override suspend fun getMangaById(id: Long): Manga {
|
override suspend fun getMangaById(id: Long): Manga {
|
||||||
return handler.awaitOne { mangasQueries.getMangaById(id, mangaMapper) }
|
return handler.awaitOne { mangasQueries.getMangaById(id, MangaMapper::mapManga) }
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun getMangaByIdAsFlow(id: Long): Flow<Manga> {
|
override suspend fun getMangaByIdAsFlow(id: Long): Flow<Manga> {
|
||||||
return handler.subscribeToOne { mangasQueries.getMangaById(id, mangaMapper) }
|
return handler.subscribeToOne { mangasQueries.getMangaById(id, MangaMapper::mapManga) }
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun getMangaByUrlAndSourceId(url: String, sourceId: Long): Manga? {
|
override suspend fun getMangaByUrlAndSourceId(url: String, sourceId: Long): Manga? {
|
||||||
@ -31,7 +31,7 @@ class MangaRepositoryImpl(
|
|||||||
mangasQueries.getMangaByUrlAndSource(
|
mangasQueries.getMangaByUrlAndSource(
|
||||||
url,
|
url,
|
||||||
sourceId,
|
sourceId,
|
||||||
mangaMapper,
|
MangaMapper::mapManga,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -41,34 +41,34 @@ class MangaRepositoryImpl(
|
|||||||
mangasQueries.getMangaByUrlAndSource(
|
mangasQueries.getMangaByUrlAndSource(
|
||||||
url,
|
url,
|
||||||
sourceId,
|
sourceId,
|
||||||
mangaMapper,
|
MangaMapper::mapManga,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun getFavorites(): List<Manga> {
|
override suspend fun getFavorites(): List<Manga> {
|
||||||
return handler.awaitList { mangasQueries.getFavorites(mangaMapper) }
|
return handler.awaitList { mangasQueries.getFavorites(MangaMapper::mapManga) }
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun getLibraryManga(): List<LibraryManga> {
|
override suspend fun getLibraryManga(): List<LibraryManga> {
|
||||||
return handler.awaitListExecutable { (handler as AndroidDatabaseHandler).getLibraryQuery() }.map(libraryViewMapper)
|
return handler.awaitListExecutable { (handler as AndroidDatabaseHandler).getLibraryQuery() }.map(MangaMapper::mapLibraryView)
|
||||||
// return handler.awaitList { libraryViewQueries.library(libraryManga) }
|
// return handler.awaitList { libraryViewQueries.library(MangaMapper::mapLibraryManga) }
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getLibraryMangaAsFlow(): Flow<List<LibraryManga>> {
|
override fun getLibraryMangaAsFlow(): Flow<List<LibraryManga>> {
|
||||||
return handler.subscribeToList { libraryViewQueries.library(libraryManga) }
|
return handler.subscribeToList { libraryViewQueries.library(MangaMapper::mapLibraryManga) }
|
||||||
// SY -->
|
// SY -->
|
||||||
.map { getLibraryManga() }
|
.map { getLibraryManga() }
|
||||||
// SY <--
|
// SY <--
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getFavoritesBySourceId(sourceId: Long): Flow<List<Manga>> {
|
override fun getFavoritesBySourceId(sourceId: Long): Flow<List<Manga>> {
|
||||||
return handler.subscribeToList { mangasQueries.getFavoriteBySourceId(sourceId, mangaMapper) }
|
return handler.subscribeToList { mangasQueries.getFavoriteBySourceId(sourceId, MangaMapper::mapManga) }
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun getDuplicateLibraryManga(id: Long, title: String): List<Manga> {
|
override suspend fun getDuplicateLibraryManga(id: Long, title: String): List<Manga> {
|
||||||
return handler.awaitList {
|
return handler.awaitList {
|
||||||
mangasQueries.getDuplicateLibraryManga(title, id, mangaMapper)
|
mangasQueries.getDuplicateLibraryManga(title, id, MangaMapper::mapManga)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -180,11 +180,11 @@ class MangaRepositoryImpl(
|
|||||||
|
|
||||||
// SY -->
|
// SY -->
|
||||||
override suspend fun getMangaBySourceId(sourceId: Long): List<Manga> {
|
override suspend fun getMangaBySourceId(sourceId: Long): List<Manga> {
|
||||||
return handler.awaitList { mangasQueries.getBySource(sourceId, mangaMapper) }
|
return handler.awaitList { mangasQueries.getBySource(sourceId, MangaMapper::mapManga) }
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun getAll(): List<Manga> {
|
override suspend fun getAll(): List<Manga> {
|
||||||
return handler.awaitList { mangasQueries.getAll(mangaMapper) }
|
return handler.awaitList { mangasQueries.getAll(MangaMapper::mapManga) }
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun deleteManga(mangaId: Long) {
|
override suspend fun deleteManga(mangaId: Long) {
|
||||||
@ -194,7 +194,7 @@ class MangaRepositoryImpl(
|
|||||||
override suspend fun getReadMangaNotInLibrary(): List<LibraryManga> {
|
override suspend fun getReadMangaNotInLibrary(): List<LibraryManga> {
|
||||||
return handler.awaitListExecutable {
|
return handler.awaitListExecutable {
|
||||||
(handler as AndroidDatabaseHandler).getLibraryQuery("M.favorite = 0 AND C.readCount != 0")
|
(handler as AndroidDatabaseHandler).getLibraryQuery("M.favorite = 0 AND C.readCount != 0")
|
||||||
}.map(libraryViewMapper)
|
}.map(MangaMapper::mapLibraryView)
|
||||||
}
|
}
|
||||||
// SY <--
|
// SY <--
|
||||||
}
|
}
|
||||||
|
@ -2,9 +2,21 @@ package tachiyomi.data.manga
|
|||||||
|
|
||||||
import tachiyomi.domain.manga.model.MergedMangaReference
|
import tachiyomi.domain.manga.model.MergedMangaReference
|
||||||
|
|
||||||
val mergedMangaReferenceMapper =
|
object MergedMangaMapper {
|
||||||
{ id: Long, isInfoManga: Boolean, getChapterUpdates: Boolean, chapterSortMode: Long, chapterPriority: Long, downloadChapters: Boolean, mergeId: Long, mergeUrl: String, mangaId: Long?, mangaUrl: String, mangaSourceId: Long ->
|
fun map(
|
||||||
MergedMangaReference(
|
id: Long,
|
||||||
|
isInfoManga: Boolean,
|
||||||
|
getChapterUpdates: Boolean,
|
||||||
|
chapterSortMode: Long,
|
||||||
|
chapterPriority: Long,
|
||||||
|
downloadChapters: Boolean,
|
||||||
|
mergeId: Long,
|
||||||
|
mergeUrl: String,
|
||||||
|
mangaId: Long?,
|
||||||
|
mangaUrl: String,
|
||||||
|
mangaSourceId: Long,
|
||||||
|
): MergedMangaReference {
|
||||||
|
return MergedMangaReference(
|
||||||
id = id,
|
id = id,
|
||||||
isInfoManga = isInfoManga,
|
isInfoManga = isInfoManga,
|
||||||
getChapterUpdates = getChapterUpdates,
|
getChapterUpdates = getChapterUpdates,
|
||||||
@ -18,3 +30,4 @@ val mergedMangaReferenceMapper =
|
|||||||
mangaSourceId = mangaSourceId,
|
mangaSourceId = mangaSourceId,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
}
|
@ -1,14 +0,0 @@
|
|||||||
package tachiyomi.data.manga
|
|
||||||
|
|
||||||
import exh.metadata.sql.models.SearchMetadata
|
|
||||||
|
|
||||||
val searchMetadataMapper: (Long, String?, String, String?, Long) -> SearchMetadata =
|
|
||||||
{ mangaId, uploader, extra, indexedExtra, extraVersion ->
|
|
||||||
SearchMetadata(
|
|
||||||
mangaId = mangaId,
|
|
||||||
uploader = uploader,
|
|
||||||
extra = extra,
|
|
||||||
indexedExtra = indexedExtra,
|
|
||||||
extraVersion = extraVersion.toInt(),
|
|
||||||
)
|
|
||||||
}
|
|
@ -1,14 +0,0 @@
|
|||||||
package tachiyomi.data.manga
|
|
||||||
|
|
||||||
import exh.metadata.sql.models.SearchTag
|
|
||||||
|
|
||||||
val searchTagMapper: (Long, Long, String?, String, Long) -> SearchTag =
|
|
||||||
{ id, mangaId, namespace, name, type ->
|
|
||||||
SearchTag(
|
|
||||||
id = id,
|
|
||||||
mangaId = mangaId,
|
|
||||||
namespace = namespace,
|
|
||||||
name = name,
|
|
||||||
type = type.toInt(),
|
|
||||||
)
|
|
||||||
}
|
|
@ -1,13 +0,0 @@
|
|||||||
package tachiyomi.data.manga
|
|
||||||
|
|
||||||
import exh.metadata.sql.models.SearchTitle
|
|
||||||
|
|
||||||
val searchTitleMapper: (Long, Long, String, Long) -> SearchTitle =
|
|
||||||
{ id, mangaId, title, type ->
|
|
||||||
SearchTitle(
|
|
||||||
id = id,
|
|
||||||
mangaId = mangaId,
|
|
||||||
title = title,
|
|
||||||
type = type.toInt(),
|
|
||||||
)
|
|
||||||
}
|
|
@ -2,12 +2,18 @@ package tachiyomi.data.source
|
|||||||
|
|
||||||
import tachiyomi.domain.source.model.FeedSavedSearch
|
import tachiyomi.domain.source.model.FeedSavedSearch
|
||||||
|
|
||||||
val feedSavedSearchMapper: (Long, Long, Long?, Boolean) -> FeedSavedSearch =
|
object FeedSavedSearchMapper {
|
||||||
{ id, source, savedSearch, global ->
|
fun map(
|
||||||
FeedSavedSearch(
|
id: Long,
|
||||||
|
source: Long,
|
||||||
|
savedSearch: Long?,
|
||||||
|
global: Boolean
|
||||||
|
): FeedSavedSearch {
|
||||||
|
return FeedSavedSearch(
|
||||||
id = id,
|
id = id,
|
||||||
source = source,
|
source = source,
|
||||||
savedSearch = savedSearch,
|
savedSearch = savedSearch,
|
||||||
global = global,
|
global = global,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
}
|
@ -11,15 +11,15 @@ class FeedSavedSearchRepositoryImpl(
|
|||||||
) : FeedSavedSearchRepository {
|
) : FeedSavedSearchRepository {
|
||||||
|
|
||||||
override suspend fun getGlobal(): List<FeedSavedSearch> {
|
override suspend fun getGlobal(): List<FeedSavedSearch> {
|
||||||
return handler.awaitList { feed_saved_searchQueries.selectAllGlobal(feedSavedSearchMapper) }
|
return handler.awaitList { feed_saved_searchQueries.selectAllGlobal(FeedSavedSearchMapper::map) }
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getGlobalAsFlow(): Flow<List<FeedSavedSearch>> {
|
override fun getGlobalAsFlow(): Flow<List<FeedSavedSearch>> {
|
||||||
return handler.subscribeToList { feed_saved_searchQueries.selectAllGlobal(feedSavedSearchMapper) }
|
return handler.subscribeToList { feed_saved_searchQueries.selectAllGlobal(FeedSavedSearchMapper::map) }
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun getGlobalFeedSavedSearch(): List<SavedSearch> {
|
override suspend fun getGlobalFeedSavedSearch(): List<SavedSearch> {
|
||||||
return handler.awaitList { feed_saved_searchQueries.selectGlobalFeedSavedSearch(savedSearchMapper) }
|
return handler.awaitList { feed_saved_searchQueries.selectGlobalFeedSavedSearch(SavedSearchMapper::map) }
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun countGlobal(): Long {
|
override suspend fun countGlobal(): Long {
|
||||||
@ -27,15 +27,15 @@ class FeedSavedSearchRepositoryImpl(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun getBySourceId(sourceId: Long): List<FeedSavedSearch> {
|
override suspend fun getBySourceId(sourceId: Long): List<FeedSavedSearch> {
|
||||||
return handler.awaitList { feed_saved_searchQueries.selectBySource(sourceId, feedSavedSearchMapper) }
|
return handler.awaitList { feed_saved_searchQueries.selectBySource(sourceId, FeedSavedSearchMapper::map) }
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getBySourceIdAsFlow(sourceId: Long): Flow<List<FeedSavedSearch>> {
|
override fun getBySourceIdAsFlow(sourceId: Long): Flow<List<FeedSavedSearch>> {
|
||||||
return handler.subscribeToList { feed_saved_searchQueries.selectBySource(sourceId, feedSavedSearchMapper) }
|
return handler.subscribeToList { feed_saved_searchQueries.selectBySource(sourceId, FeedSavedSearchMapper::map) }
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun getBySourceIdFeedSavedSearch(sourceId: Long): List<SavedSearch> {
|
override suspend fun getBySourceIdFeedSavedSearch(sourceId: Long): List<SavedSearch> {
|
||||||
return handler.awaitList { feed_saved_searchQueries.selectSourceFeedSavedSearch(sourceId, savedSearchMapper) }
|
return handler.awaitList { feed_saved_searchQueries.selectSourceFeedSavedSearch(sourceId, SavedSearchMapper::map) }
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun countBySourceId(sourceId: Long): Long {
|
override suspend fun countBySourceId(sourceId: Long): Long {
|
||||||
|
@ -2,9 +2,15 @@ package tachiyomi.data.source
|
|||||||
|
|
||||||
import tachiyomi.domain.source.model.SavedSearch
|
import tachiyomi.domain.source.model.SavedSearch
|
||||||
|
|
||||||
val savedSearchMapper: (Long, Long, String, String?, String?) -> SavedSearch =
|
object SavedSearchMapper {
|
||||||
{ id, source, name, query, filtersJson ->
|
fun map(
|
||||||
SavedSearch(
|
id: Long,
|
||||||
|
source: Long,
|
||||||
|
name: String,
|
||||||
|
query: String?,
|
||||||
|
filtersJson: String?
|
||||||
|
): SavedSearch {
|
||||||
|
return SavedSearch(
|
||||||
id = id,
|
id = id,
|
||||||
source = source,
|
source = source,
|
||||||
name = name,
|
name = name,
|
||||||
@ -12,3 +18,4 @@ val savedSearchMapper: (Long, Long, String, String?, String?) -> SavedSearch =
|
|||||||
filtersJson = filtersJson,
|
filtersJson = filtersJson,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
}
|
@ -10,15 +10,15 @@ class SavedSearchRepositoryImpl(
|
|||||||
) : SavedSearchRepository {
|
) : SavedSearchRepository {
|
||||||
|
|
||||||
override suspend fun getById(savedSearchId: Long): SavedSearch? {
|
override suspend fun getById(savedSearchId: Long): SavedSearch? {
|
||||||
return handler.awaitOneOrNull { saved_searchQueries.selectById(savedSearchId, savedSearchMapper) }
|
return handler.awaitOneOrNull { saved_searchQueries.selectById(savedSearchId, SavedSearchMapper::map) }
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun getBySourceId(sourceId: Long): List<SavedSearch> {
|
override suspend fun getBySourceId(sourceId: Long): List<SavedSearch> {
|
||||||
return handler.awaitList { saved_searchQueries.selectBySource(sourceId, savedSearchMapper) }
|
return handler.awaitList { saved_searchQueries.selectBySource(sourceId, SavedSearchMapper::map) }
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getBySourceIdAsFlow(sourceId: Long): Flow<List<SavedSearch>> {
|
override fun getBySourceIdAsFlow(sourceId: Long): Flow<List<SavedSearch>> {
|
||||||
return handler.subscribeToList { saved_searchQueries.selectBySource(sourceId, savedSearchMapper) }
|
return handler.subscribeToList { saved_searchQueries.selectBySource(sourceId, SavedSearchMapper::map) }
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun delete(savedSearchId: Long) {
|
override suspend fun delete(savedSearchId: Long) {
|
||||||
|
@ -1,18 +0,0 @@
|
|||||||
package tachiyomi.data.source
|
|
||||||
|
|
||||||
import tachiyomi.domain.source.model.Source
|
|
||||||
import tachiyomi.domain.source.model.StubSource
|
|
||||||
|
|
||||||
val sourceMapper: (eu.kanade.tachiyomi.source.Source) -> Source = { source ->
|
|
||||||
Source(
|
|
||||||
id = source.id,
|
|
||||||
lang = source.lang,
|
|
||||||
name = source.name,
|
|
||||||
supportsLatest = false,
|
|
||||||
isStub = false,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
val sourceDataMapper: (Long, String, String) -> StubSource = { id, lang, name ->
|
|
||||||
StubSource(id = id, lang = lang, name = name)
|
|
||||||
}
|
|
@ -1,6 +1,7 @@
|
|||||||
package tachiyomi.data.source
|
package tachiyomi.data.source
|
||||||
|
|
||||||
import eu.kanade.tachiyomi.source.CatalogueSource
|
import eu.kanade.tachiyomi.source.CatalogueSource
|
||||||
|
import eu.kanade.tachiyomi.source.Source
|
||||||
import eu.kanade.tachiyomi.source.model.FilterList
|
import eu.kanade.tachiyomi.source.model.FilterList
|
||||||
import eu.kanade.tachiyomi.source.online.HttpSource
|
import eu.kanade.tachiyomi.source.online.HttpSource
|
||||||
import exh.source.MERGED_SOURCE_ID
|
import exh.source.MERGED_SOURCE_ID
|
||||||
@ -8,38 +9,39 @@ import exh.source.isEhBasedSource
|
|||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
import kotlinx.coroutines.flow.map
|
import kotlinx.coroutines.flow.map
|
||||||
import tachiyomi.data.DatabaseHandler
|
import tachiyomi.data.DatabaseHandler
|
||||||
import tachiyomi.domain.source.model.Source
|
|
||||||
import tachiyomi.domain.source.model.SourceWithCount
|
import tachiyomi.domain.source.model.SourceWithCount
|
||||||
import tachiyomi.domain.source.model.StubSource
|
import tachiyomi.domain.source.model.StubSource
|
||||||
import tachiyomi.domain.source.repository.SourcePagingSourceType
|
import tachiyomi.domain.source.repository.SourcePagingSourceType
|
||||||
import tachiyomi.domain.source.repository.SourceRepository
|
import tachiyomi.domain.source.repository.SourceRepository
|
||||||
import tachiyomi.domain.source.service.SourceManager
|
import tachiyomi.domain.source.service.SourceManager
|
||||||
|
import tachiyomi.domain.source.model.Source as DomainSource
|
||||||
|
|
||||||
class SourceRepositoryImpl(
|
class SourceRepositoryImpl(
|
||||||
private val sourceManager: SourceManager,
|
private val sourceManager: SourceManager,
|
||||||
private val handler: DatabaseHandler,
|
private val handler: DatabaseHandler,
|
||||||
) : SourceRepository {
|
) : SourceRepository {
|
||||||
|
|
||||||
override fun getSources(): Flow<List<Source>> {
|
override fun getSources(): Flow<List<DomainSource>> {
|
||||||
return sourceManager.catalogueSources.map { sources ->
|
return sourceManager.catalogueSources.map { sources ->
|
||||||
sources.map {
|
sources.map {
|
||||||
sourceMapper(it).copy(
|
mapSourceToDomainSource(it).copy(
|
||||||
supportsLatest = it.supportsLatest,
|
supportsLatest = it.supportsLatest,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getOnlineSources(): Flow<List<Source>> {
|
override fun getOnlineSources(): Flow<List<DomainSource>> {
|
||||||
return sourceManager.catalogueSources.map { sources ->
|
return sourceManager.catalogueSources.map { sources ->
|
||||||
sources
|
sources
|
||||||
.filterIsInstance<HttpSource>()
|
.filterIsInstance<HttpSource>()
|
||||||
.map(sourceMapper)
|
.map(::mapSourceToDomainSource)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getSourcesWithFavoriteCount(): Flow<List<Pair<Source, Long>>> {
|
override fun getSourcesWithFavoriteCount(): Flow<List<Pair<DomainSource, Long>>> {
|
||||||
val sourceIdWithFavoriteCount = handler.subscribeToList { mangasQueries.getSourceIdWithFavoriteCount() }
|
val sourceIdWithFavoriteCount =
|
||||||
|
handler.subscribeToList { mangasQueries.getSourceIdWithFavoriteCount() }
|
||||||
return sourceIdWithFavoriteCount.map { sourceIdsWithCount ->
|
return sourceIdWithFavoriteCount.map { sourceIdsWithCount ->
|
||||||
sourceIdsWithCount
|
sourceIdsWithCount
|
||||||
// SY -->
|
// SY -->
|
||||||
@ -47,7 +49,7 @@ class SourceRepositoryImpl(
|
|||||||
// SY <--
|
// SY <--
|
||||||
.map { (sourceId, count) ->
|
.map { (sourceId, count) ->
|
||||||
val source = sourceManager.getOrStub(sourceId)
|
val source = sourceManager.getOrStub(sourceId)
|
||||||
val domainSource = sourceMapper(source).copy(
|
val domainSource = mapSourceToDomainSource(source).copy(
|
||||||
isStub = source is StubSource,
|
isStub = source is StubSource,
|
||||||
)
|
)
|
||||||
domainSource to count
|
domainSource to count
|
||||||
@ -56,11 +58,12 @@ class SourceRepositoryImpl(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun getSourcesWithNonLibraryManga(): Flow<List<SourceWithCount>> {
|
override fun getSourcesWithNonLibraryManga(): Flow<List<SourceWithCount>> {
|
||||||
val sourceIdWithNonLibraryManga = handler.subscribeToList { mangasQueries.getSourceIdsWithNonLibraryManga() }
|
val sourceIdWithNonLibraryManga =
|
||||||
|
handler.subscribeToList { mangasQueries.getSourceIdsWithNonLibraryManga() }
|
||||||
return sourceIdWithNonLibraryManga.map { sourceId ->
|
return sourceIdWithNonLibraryManga.map { sourceId ->
|
||||||
sourceId.map { (sourceId, count) ->
|
sourceId.map { (sourceId, count) ->
|
||||||
val source = sourceManager.getOrStub(sourceId)
|
val source = sourceManager.getOrStub(sourceId)
|
||||||
val domainSource = sourceMapper(source).copy(
|
val domainSource = mapSourceToDomainSource(source).copy(
|
||||||
isStub = source is StubSource,
|
isStub = source is StubSource,
|
||||||
)
|
)
|
||||||
SourceWithCount(domainSource, count)
|
SourceWithCount(domainSource, count)
|
||||||
@ -101,4 +104,12 @@ class SourceRepositoryImpl(
|
|||||||
// SY <--
|
// SY <--
|
||||||
return SourceLatestPagingSource(source)
|
return SourceLatestPagingSource(source)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun mapSourceToDomainSource(source: Source): DomainSource = DomainSource(
|
||||||
|
id = source.id,
|
||||||
|
lang = source.lang,
|
||||||
|
name = source.name,
|
||||||
|
supportsLatest = false,
|
||||||
|
isStub = false,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
@ -10,14 +10,20 @@ class StubSourceRepositoryImpl(
|
|||||||
) : StubSourceRepository {
|
) : StubSourceRepository {
|
||||||
|
|
||||||
override fun subscribeAll(): Flow<List<StubSource>> {
|
override fun subscribeAll(): Flow<List<StubSource>> {
|
||||||
return handler.subscribeToList { sourcesQueries.findAll(sourceDataMapper) }
|
return handler.subscribeToList { sourcesQueries.findAll(::mapStubSource) }
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun getStubSource(id: Long): StubSource? {
|
override suspend fun getStubSource(id: Long): StubSource? {
|
||||||
return handler.awaitOneOrNull { sourcesQueries.findOne(id, sourceDataMapper) }
|
return handler.awaitOneOrNull { sourcesQueries.findOne(id, ::mapStubSource) }
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun upsertStubSource(id: Long, lang: String, name: String) {
|
override suspend fun upsertStubSource(id: Long, lang: String, name: String) {
|
||||||
handler.await { sourcesQueries.upsert(id, lang, name) }
|
handler.await { sourcesQueries.upsert(id, lang, name) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun mapStubSource(
|
||||||
|
id: Long,
|
||||||
|
lang: String,
|
||||||
|
name: String,
|
||||||
|
): StubSource = StubSource(id = id, lang = lang, name = name)
|
||||||
}
|
}
|
||||||
|
@ -1,36 +0,0 @@
|
|||||||
package tachiyomi.data.track
|
|
||||||
|
|
||||||
import tachiyomi.domain.track.model.Track
|
|
||||||
|
|
||||||
val trackMapper: (
|
|
||||||
Long,
|
|
||||||
Long,
|
|
||||||
Long,
|
|
||||||
Long,
|
|
||||||
Long?,
|
|
||||||
String,
|
|
||||||
Double,
|
|
||||||
Long,
|
|
||||||
Long,
|
|
||||||
Double,
|
|
||||||
String,
|
|
||||||
Long,
|
|
||||||
Long,
|
|
||||||
) -> Track =
|
|
||||||
{ id, mangaId, syncId, remoteId, libraryId, title, lastChapterRead, totalChapters, status, score, remoteUrl, startDate, finishDate ->
|
|
||||||
Track(
|
|
||||||
id = id,
|
|
||||||
mangaId = mangaId,
|
|
||||||
syncId = syncId,
|
|
||||||
remoteId = remoteId,
|
|
||||||
libraryId = libraryId,
|
|
||||||
title = title,
|
|
||||||
lastChapterRead = lastChapterRead,
|
|
||||||
totalChapters = totalChapters,
|
|
||||||
status = status,
|
|
||||||
score = score,
|
|
||||||
remoteUrl = remoteUrl,
|
|
||||||
startDate = startDate,
|
|
||||||
finishDate = finishDate,
|
|
||||||
)
|
|
||||||
}
|
|
@ -10,38 +10,38 @@ class TrackRepositoryImpl(
|
|||||||
) : TrackRepository {
|
) : TrackRepository {
|
||||||
|
|
||||||
override suspend fun getTrackById(id: Long): Track? {
|
override suspend fun getTrackById(id: Long): Track? {
|
||||||
return handler.awaitOneOrNull { manga_syncQueries.getTrackById(id, trackMapper) }
|
return handler.awaitOneOrNull { manga_syncQueries.getTrackById(id, ::mapTrack) }
|
||||||
}
|
}
|
||||||
|
|
||||||
// SY -->
|
// SY -->
|
||||||
override suspend fun getTracks(): List<Track> {
|
override suspend fun getTracks(): List<Track> {
|
||||||
return handler.awaitList {
|
return handler.awaitList {
|
||||||
manga_syncQueries.getTracks(trackMapper)
|
manga_syncQueries.getTracks(::mapTrack)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun getTracksByMangaIds(mangaIds: List<Long>): List<Track> {
|
override suspend fun getTracksByMangaIds(mangaIds: List<Long>): List<Track> {
|
||||||
return handler.awaitList {
|
return handler.awaitList {
|
||||||
manga_syncQueries.getTracksByMangaIds(mangaIds, trackMapper)
|
manga_syncQueries.getTracksByMangaIds(mangaIds, ::mapTrack)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// SY <--
|
// SY <--
|
||||||
|
|
||||||
override suspend fun getTracksByMangaId(mangaId: Long): List<Track> {
|
override suspend fun getTracksByMangaId(mangaId: Long): List<Track> {
|
||||||
return handler.awaitList {
|
return handler.awaitList {
|
||||||
manga_syncQueries.getTracksByMangaId(mangaId, trackMapper)
|
manga_syncQueries.getTracksByMangaId(mangaId, ::mapTrack)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getTracksAsFlow(): Flow<List<Track>> {
|
override fun getTracksAsFlow(): Flow<List<Track>> {
|
||||||
return handler.subscribeToList {
|
return handler.subscribeToList {
|
||||||
manga_syncQueries.getTracks(trackMapper)
|
manga_syncQueries.getTracks(::mapTrack)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getTracksByMangaIdAsFlow(mangaId: Long): Flow<List<Track>> {
|
override fun getTracksByMangaIdAsFlow(mangaId: Long): Flow<List<Track>> {
|
||||||
return handler.subscribeToList {
|
return handler.subscribeToList {
|
||||||
manga_syncQueries.getTracksByMangaId(mangaId, trackMapper)
|
manga_syncQueries.getTracksByMangaId(mangaId, ::mapTrack)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,4 +82,34 @@ class TrackRepositoryImpl(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun mapTrack(
|
||||||
|
id: Long,
|
||||||
|
mangaId: Long,
|
||||||
|
syncId: Long,
|
||||||
|
remoteId: Long,
|
||||||
|
libraryId: Long?,
|
||||||
|
title: String,
|
||||||
|
lastChapterRead: Double,
|
||||||
|
totalChapters: Long,
|
||||||
|
status: Long,
|
||||||
|
score: Double,
|
||||||
|
remoteUrl: String,
|
||||||
|
startDate: Long,
|
||||||
|
finishDate: Long,
|
||||||
|
): Track = Track(
|
||||||
|
id = id,
|
||||||
|
mangaId = mangaId,
|
||||||
|
syncId = syncId,
|
||||||
|
remoteId = remoteId,
|
||||||
|
libraryId = libraryId,
|
||||||
|
title = title,
|
||||||
|
lastChapterRead = lastChapterRead,
|
||||||
|
totalChapters = totalChapters,
|
||||||
|
status = status,
|
||||||
|
score = score,
|
||||||
|
remoteUrl = remoteUrl,
|
||||||
|
startDate = startDate,
|
||||||
|
finishDate = finishDate,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
@ -1,67 +0,0 @@
|
|||||||
package tachiyomi.data.updates
|
|
||||||
|
|
||||||
import tachiyomi.domain.manga.model.MangaCover
|
|
||||||
import tachiyomi.domain.updates.model.UpdatesWithRelations
|
|
||||||
import tachiyomi.view.UpdatesView
|
|
||||||
|
|
||||||
val updateWithRelationMapper: (
|
|
||||||
Long,
|
|
||||||
String,
|
|
||||||
Long,
|
|
||||||
String,
|
|
||||||
String?,
|
|
||||||
Boolean,
|
|
||||||
Boolean,
|
|
||||||
Long,
|
|
||||||
Long,
|
|
||||||
Boolean,
|
|
||||||
String?,
|
|
||||||
Long,
|
|
||||||
Long,
|
|
||||||
Long,
|
|
||||||
) -> UpdatesWithRelations = {
|
|
||||||
mangaId, mangaTitle, chapterId, chapterName, scanlator, read, bookmark, lastPageRead, sourceId, favorite, thumbnailUrl, coverLastModified, _, dateFetch ->
|
|
||||||
UpdatesWithRelations(
|
|
||||||
mangaId = mangaId,
|
|
||||||
// SY -->
|
|
||||||
ogMangaTitle = mangaTitle,
|
|
||||||
// SY <--
|
|
||||||
chapterId = chapterId,
|
|
||||||
chapterName = chapterName,
|
|
||||||
scanlator = scanlator,
|
|
||||||
read = read,
|
|
||||||
bookmark = bookmark,
|
|
||||||
lastPageRead = lastPageRead,
|
|
||||||
sourceId = sourceId,
|
|
||||||
dateFetch = dateFetch,
|
|
||||||
coverData = MangaCover(
|
|
||||||
mangaId = mangaId,
|
|
||||||
sourceId = sourceId,
|
|
||||||
isMangaFavorite = favorite,
|
|
||||||
url = thumbnailUrl,
|
|
||||||
lastModified = coverLastModified,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
val updatesViewMapper: (UpdatesView) -> UpdatesWithRelations = {
|
|
||||||
UpdatesWithRelations(
|
|
||||||
mangaId = it.mangaId,
|
|
||||||
ogMangaTitle = it.mangaTitle,
|
|
||||||
chapterId = it.chapterId,
|
|
||||||
chapterName = it.chapterName,
|
|
||||||
scanlator = it.scanlator,
|
|
||||||
read = it.read,
|
|
||||||
bookmark = it.bookmark,
|
|
||||||
lastPageRead = it.last_page_read,
|
|
||||||
sourceId = it.source,
|
|
||||||
dateFetch = it.datefetch,
|
|
||||||
coverData = MangaCover(
|
|
||||||
mangaId = it.mangaId,
|
|
||||||
sourceId = it.source,
|
|
||||||
isMangaFavorite = it.favorite,
|
|
||||||
url = it.thumbnailUrl,
|
|
||||||
lastModified = it.coverLastModified,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
}
|
|
@ -4,8 +4,10 @@ import kotlinx.coroutines.flow.Flow
|
|||||||
import kotlinx.coroutines.flow.map
|
import kotlinx.coroutines.flow.map
|
||||||
import tachiyomi.data.AndroidDatabaseHandler
|
import tachiyomi.data.AndroidDatabaseHandler
|
||||||
import tachiyomi.data.DatabaseHandler
|
import tachiyomi.data.DatabaseHandler
|
||||||
|
import tachiyomi.domain.manga.model.MangaCover
|
||||||
import tachiyomi.domain.updates.model.UpdatesWithRelations
|
import tachiyomi.domain.updates.model.UpdatesWithRelations
|
||||||
import tachiyomi.domain.updates.repository.UpdatesRepository
|
import tachiyomi.domain.updates.repository.UpdatesRepository
|
||||||
|
import tachiyomi.view.UpdatesView
|
||||||
|
|
||||||
class UpdatesRepositoryImpl(
|
class UpdatesRepositoryImpl(
|
||||||
private val databaseHandler: DatabaseHandler,
|
private val databaseHandler: DatabaseHandler,
|
||||||
@ -21,17 +23,17 @@ class UpdatesRepositoryImpl(
|
|||||||
read = read,
|
read = read,
|
||||||
after = after,
|
after = after,
|
||||||
limit = limit,
|
limit = limit,
|
||||||
mapper = updateWithRelationMapper,
|
mapper = ::mapUpdatesWithRelations,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun subscribeAll(after: Long, limit: Long): Flow<List<UpdatesWithRelations>> {
|
override fun subscribeAll(after: Long, limit: Long): Flow<List<UpdatesWithRelations>> {
|
||||||
return databaseHandler.subscribeToList {
|
return databaseHandler.subscribeToList {
|
||||||
updatesViewQueries.getRecentUpdates(after, limit, updateWithRelationMapper)
|
updatesViewQueries.getRecentUpdates(after, limit, ::mapUpdatesWithRelations)
|
||||||
}.map {
|
}.map {
|
||||||
databaseHandler.awaitListExecutable { (databaseHandler as AndroidDatabaseHandler).getUpdatesQuery(after, limit) }
|
databaseHandler.awaitListExecutable { (databaseHandler as AndroidDatabaseHandler).getUpdatesQuery(after, limit) }
|
||||||
.map(updatesViewMapper)
|
.map(::mapUpdatesView)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,8 +47,67 @@ class UpdatesRepositoryImpl(
|
|||||||
read = read,
|
read = read,
|
||||||
after = after,
|
after = after,
|
||||||
limit = limit,
|
limit = limit,
|
||||||
mapper = updateWithRelationMapper,
|
mapper = ::mapUpdatesWithRelations,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun mapUpdatesWithRelations(
|
||||||
|
mangaId: Long,
|
||||||
|
mangaTitle: String,
|
||||||
|
chapterId: Long,
|
||||||
|
chapterName: String,
|
||||||
|
scanlator: String?,
|
||||||
|
read: Boolean,
|
||||||
|
bookmark: Boolean,
|
||||||
|
lastPageRead: Long,
|
||||||
|
sourceId: Long,
|
||||||
|
favorite: Boolean,
|
||||||
|
thumbnailUrl: String?,
|
||||||
|
coverLastModified: Long,
|
||||||
|
dateUpload: Long,
|
||||||
|
dateFetch: Long,
|
||||||
|
): UpdatesWithRelations = UpdatesWithRelations(
|
||||||
|
mangaId = mangaId,
|
||||||
|
// SY -->
|
||||||
|
ogMangaTitle = mangaTitle,
|
||||||
|
// SY <--
|
||||||
|
chapterId = chapterId,
|
||||||
|
chapterName = chapterName,
|
||||||
|
scanlator = scanlator,
|
||||||
|
read = read,
|
||||||
|
bookmark = bookmark,
|
||||||
|
lastPageRead = lastPageRead,
|
||||||
|
sourceId = sourceId,
|
||||||
|
dateFetch = dateFetch,
|
||||||
|
coverData = MangaCover(
|
||||||
|
mangaId = mangaId,
|
||||||
|
sourceId = sourceId,
|
||||||
|
isMangaFavorite = favorite,
|
||||||
|
url = thumbnailUrl,
|
||||||
|
lastModified = coverLastModified,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
fun mapUpdatesView(updatesView: UpdatesView): UpdatesWithRelations {
|
||||||
|
return UpdatesWithRelations(
|
||||||
|
mangaId = updatesView.mangaId,
|
||||||
|
ogMangaTitle = updatesView.mangaTitle,
|
||||||
|
chapterId = updatesView.chapterId,
|
||||||
|
chapterName = updatesView.chapterName,
|
||||||
|
scanlator = updatesView.scanlator,
|
||||||
|
read = updatesView.read,
|
||||||
|
bookmark = updatesView.bookmark,
|
||||||
|
lastPageRead = updatesView.last_page_read,
|
||||||
|
sourceId = updatesView.source,
|
||||||
|
dateFetch = updatesView.datefetch,
|
||||||
|
coverData = MangaCover(
|
||||||
|
mangaId = updatesView.mangaId,
|
||||||
|
sourceId = updatesView.source,
|
||||||
|
isMangaFavorite = updatesView.favorite,
|
||||||
|
url = updatesView.thumbnailUrl,
|
||||||
|
lastModified = updatesView.coverLastModified,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user