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:
Caleb Morris 2023-10-21 18:42:09 -07:00 committed by Jobobby04
parent b131e1ca1f
commit 48ef273fb2
30 changed files with 518 additions and 437 deletions

View File

@ -58,7 +58,7 @@ import tachiyomi.core.preference.Preference
import tachiyomi.core.preference.PreferenceStore
import tachiyomi.core.util.system.logcat
import tachiyomi.data.DatabaseHandler
import tachiyomi.data.manga.mangaMapper
import tachiyomi.data.manga.MangaMapper
import tachiyomi.domain.backup.service.BackupPreferences
import tachiyomi.domain.category.interactor.GetCategories
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) {
handler.awaitList { mangasQueries.getReadMangaNotInLibrary(mangaMapper) }
handler.awaitList { mangasQueries.getReadMangaNotInLibrary(MangaMapper::mapManga) }
} else {
emptyList()
} + getMergedManga.await() // SY <--

View File

@ -38,8 +38,8 @@ import tachiyomi.data.Manga_sync
import tachiyomi.data.Mangas
import tachiyomi.data.StringListAndColumnAdapter
import tachiyomi.data.UpdateStrategyColumnAdapter
import tachiyomi.data.manga.mangaMapper
import tachiyomi.data.manga.mergedMangaReferenceMapper
import tachiyomi.data.manga.MangaMapper
import tachiyomi.data.manga.MergedMangaMapper
import tachiyomi.domain.category.interactor.GetCategories
import tachiyomi.domain.chapter.model.Chapter
import tachiyomi.domain.history.model.HistoryUpdate
@ -689,7 +689,7 @@ class BackupRestorer(
*/
internal suspend fun restoreMergedMangaReferencesForManga(mergeMangaId: Long, backupMergedMangaReferences: List<BackupMergedMangaReference>) {
// 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
backupMergedMangaReferences.forEach { backupMergedMangaReference ->
@ -697,7 +697,7 @@ class BackupRestorer(
// Store the inserted id in the backupMergedMangaReference
if (dbMergedMangaReferences.none { backupMergedMangaReference.mergeUrl == it.mergeUrl && backupMergedMangaReference.mangaUrl == it.mangaUrl }) {
// 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 {
handler.await {
mergedQueries.insert(

View File

@ -48,8 +48,8 @@ import tachiyomi.core.preference.getEnum
import tachiyomi.core.preference.minusAssign
import tachiyomi.core.util.system.logcat
import tachiyomi.data.DatabaseHandler
import tachiyomi.data.category.categoryMapper
import tachiyomi.data.chapter.chapterMapper
import tachiyomi.data.category.CategoryMapper
import tachiyomi.data.chapter.ChapterMapper
import tachiyomi.domain.backup.service.BackupPreferences
import tachiyomi.domain.chapter.interactor.DeleteChapters
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 chapters = runBlocking { handler.awaitList { ehQueries.getChaptersByMangaIds(mergedMangas.map { it.id }, chapterMapper) } }
val mergedMangaChapters = runBlocking { handler.awaitList { ehQueries.getChaptersByMangaIds(loadedMangaList.map { it.manga.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::mapChapter) } }
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 } }
@ -430,7 +430,7 @@ object EXHMigrations {
}
runBlocking {
handler.await(true) {
categoriesQueries.getCategories(categoryMapper).executeAsList()
categoriesQueries.getCategories(CategoryMapper::mapCategory).executeAsList()
.filter { (it.flags and 0b00111100L) == 0b00100000L }
.forEach {
categoriesQueries.update(

View File

@ -2,11 +2,18 @@ package tachiyomi.data.category
import tachiyomi.domain.category.model.Category
val categoryMapper: (Long, String, Long, Long) -> Category = { id, name, order, flags ->
Category(
object CategoryMapper {
fun mapCategory(
id: Long,
name: String,
order: Long,
flags: Long,
): Category {
return Category(
id = id,
name = name,
order = order,
flags = flags,
)
}
}

View File

@ -12,26 +12,26 @@ class CategoryRepositoryImpl(
) : CategoryRepository {
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> {
return handler.awaitList { categoriesQueries.getCategories(categoryMapper) }
return handler.awaitList { categoriesQueries.getCategories(CategoryMapper::mapCategory) }
}
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> {
return handler.awaitList {
categoriesQueries.getCategoriesByMangaId(mangaId, categoryMapper)
categoriesQueries.getCategoriesByMangaId(mangaId, CategoryMapper::mapCategory)
}
}
override fun getCategoriesByMangaIdAsFlow(mangaId: Long): Flow<List<Category>> {
return handler.subscribeToList {
categoriesQueries.getCategoriesByMangaId(mangaId, categoryMapper)
categoriesQueries.getCategoriesByMangaId(mangaId, CategoryMapper::mapCategory)
}
}

View File

@ -2,23 +2,22 @@ package tachiyomi.data.chapter
import tachiyomi.domain.chapter.model.Chapter
val chapterMapper: (
Long,
Long,
String,
String,
String?,
Boolean,
Boolean,
Long,
Double,
Long,
Long,
Long,
Long,
) -> Chapter =
{ id, mangaId, url, name, scanlator, read, bookmark, lastPageRead, chapterNumber, sourceOrder, dateFetch, dateUpload, lastModifiedAt ->
Chapter(
object ChapterMapper {
fun mapChapter(
id: Long,
mangaId: Long,
url: String,
name: String,
scanlator: String?,
read: Boolean,
bookmark: Boolean,
lastPageRead: Long,
chapterNumber: Double,
sourceOrder: Long,
dateFetch: Long,
dateUpload: Long,
lastModifiedAt: Long,
): Chapter = Chapter(
id = id,
mangaId = mangaId,
read = read,

View File

@ -77,27 +77,27 @@ class ChapterRepositoryImpl(
}
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> {
return handler.awaitList {
chaptersQueries.getBookmarkedChaptersByMangaId(
mangaId,
chapterMapper,
ChapterMapper::mapChapter,
)
}
}
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>> {
return handler.subscribeToList {
chaptersQueries.getChaptersByMangaId(
mangaId,
chapterMapper,
ChapterMapper::mapChapter,
)
}
}
@ -107,22 +107,22 @@ class ChapterRepositoryImpl(
chaptersQueries.getChapterByUrlAndMangaId(
url,
mangaId,
chapterMapper,
ChapterMapper::mapChapter,
)
}
}
// SY -->
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> {
return handler.awaitList { chaptersQueries.getMergedChaptersByMangaId(mangaId, chapterMapper) }
return handler.awaitList { chaptersQueries.getMergedChaptersByMangaId(mangaId, ChapterMapper::mapChapter) }
}
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 <--
}

View File

@ -5,30 +5,32 @@ import tachiyomi.domain.history.model.HistoryWithRelations
import tachiyomi.domain.manga.model.MangaCover
import java.util.Date
val historyMapper: (Long, Long, Date?, Long) -> History = { id, chapterId, readAt, readDuration ->
History(
object HistoryMapper {
fun mapHistory(
id: Long,
chapterId: Long,
readAt: Date?,
readDuration: Long,
): History = History(
id = id,
chapterId = chapterId,
readAt = readAt,
readDuration = readDuration,
)
}
val historyWithRelationsMapper: (
Long,
Long,
Long,
String,
String?,
Long,
Boolean,
Long,
Double,
Date?,
Long,
) -> HistoryWithRelations = {
historyId, mangaId, chapterId, title, thumbnailUrl, sourceId, isFavorite, coverLastModified, chapterNumber, readAt, readDuration ->
HistoryWithRelations(
fun mapHistoryWithRelations(
historyId: Long,
mangaId: Long,
chapterId: Long,
title: String,
thumbnailUrl: String?,
sourceId: Long,
isFavorite: Boolean,
coverLastModified: Long,
chapterNumber: Double,
readAt: Date?,
readDuration: Long,
): HistoryWithRelations = HistoryWithRelations(
id = historyId,
chapterId = chapterId,
mangaId = mangaId,

View File

@ -15,13 +15,13 @@ class HistoryRepositoryImpl(
override fun getHistory(query: String): Flow<List<HistoryWithRelations>> {
return handler.subscribeToList {
historyViewQueries.history(query, historyWithRelationsMapper)
historyViewQueries.history(query, HistoryMapper::mapHistoryWithRelations)
}
}
override suspend fun getLastHistory(): HistoryWithRelations? {
return handler.awaitOneOrNull {
historyViewQueries.getLatestHistory(historyWithRelationsMapper)
historyViewQueries.getLatestHistory(HistoryMapper::mapHistoryWithRelations)
}
}
@ -30,7 +30,7 @@ class HistoryRepositoryImpl(
}
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) {
@ -91,7 +91,7 @@ class HistoryRepositoryImpl(
}
override suspend fun getByMangaId(mangaId: Long): List<History> {
return handler.awaitList { historyQueries.getHistoryByMangaId(mangaId, historyMapper) }
return handler.awaitList { historyQueries.getHistoryByMangaId(mangaId, HistoryMapper::mapHistory) }
}
// SY <--
}

View File

@ -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,
)
}

View File

@ -28,7 +28,7 @@ class FavoritesEntryRepositoryImpl(
}
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) {
@ -45,4 +45,22 @@ class FavoritesEntryRepositoryImpl(
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,
)
}
}

View File

@ -5,9 +5,33 @@ import tachiyomi.domain.library.model.LibraryManga
import tachiyomi.domain.manga.model.Manga
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 ->
Manga(
object MangaMapper {
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,
source = source,
favorite = favorite,
@ -36,12 +60,40 @@ val mangaMapper: (Long, Long, String, String?, String?, String?, List<String>?,
lastModifiedAt = lastModifiedAt,
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 =
{ 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 ->
LibraryManga(
manga = mangaMapper(
fun mapLibraryManga(
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?,
totalCount: Long,
readCount: Double,
latestUpload: Long,
chapterFetchedAt: Long,
lastRead: Long,
bookmarkCount: Double,
category: Long,
): LibraryManga = LibraryManga(
manga = mapManga(
id,
source,
url,
@ -76,41 +128,41 @@ val libraryManga: (Long, Long, String, String?, String?, String?, List<String>?,
chapterFetchedAt = chapterFetchedAt,
lastRead = lastRead,
)
}
val libraryViewMapper: (LibraryView) -> LibraryManga = {
LibraryManga(
fun mapLibraryView(libraryView: LibraryView): LibraryManga {
return LibraryManga(
manga = Manga(
id = it._id,
source = it.source,
favorite = it.favorite,
lastUpdate = it.last_update ?: 0,
nextUpdate = it.next_update ?: 0,
dateAdded = it.date_added,
viewerFlags = it.viewer,
chapterFlags = it.chapter_flags,
coverLastModified = it.cover_last_modified,
url = it.url,
ogTitle = it.title,
ogArtist = it.artist,
ogAuthor = it.author,
ogDescription = it.description,
ogGenre = it.genre,
ogStatus = it.status,
thumbnailUrl = it.thumbnail_url,
updateStrategy = it.update_strategy,
initialized = it.initialized,
filteredScanlators = it.filtered_scanlators,
fetchInterval = it.calculate_interval.toInt(),
lastModifiedAt = it.last_modified_at,
favoriteModifiedAt = it.favorite_modified_at,
id = libraryView._id,
source = libraryView.source,
favorite = libraryView.favorite,
lastUpdate = libraryView.last_update ?: 0,
nextUpdate = libraryView.next_update ?: 0,
dateAdded = libraryView.date_added,
viewerFlags = libraryView.viewer,
chapterFlags = libraryView.chapter_flags,
coverLastModified = libraryView.cover_last_modified,
url = libraryView.url,
ogTitle = libraryView.title,
ogArtist = libraryView.artist,
ogAuthor = libraryView.author,
ogDescription = libraryView.description,
ogGenre = libraryView.genre,
ogStatus = libraryView.status,
thumbnailUrl = libraryView.thumbnail_url,
updateStrategy = libraryView.update_strategy,
initialized = libraryView.initialized,
filteredScanlators = libraryView.filtered_scanlators,
fetchInterval = libraryView.calculate_interval.toInt(),
lastModifiedAt = libraryView.last_modified_at,
favoriteModifiedAt = libraryView.favorite_modified_at,
),
category = it.category,
totalChapters = it.totalCount,
readCount = it.readCount.toLong(),
bookmarkCount = it.bookmarkCount.toLong(),
latestUpload = it.latestUpload,
chapterFetchedAt = it.chapterFetchedAt,
lastRead = it.lastRead,
category = libraryView.category,
totalChapters = libraryView.totalCount,
readCount = libraryView.readCount.toLong(),
bookmarkCount = libraryView.bookmarkCount.toLong(),
latestUpload = libraryView.latestUpload,
chapterFetchedAt = libraryView.chapterFetchedAt,
lastRead = libraryView.lastRead,
)
}
}

View File

@ -14,27 +14,27 @@ class MangaMergeRepositoryImpl(
) : MangaMergeRepository {
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>> {
return handler.subscribeToList { mergedQueries.selectAllMergedMangas(mangaMapper) }
return handler.subscribeToList { mergedQueries.selectAllMergedMangas(MangaMapper::mapManga) }
}
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>> {
return handler.subscribeToList { mergedQueries.selectMergedMangasById(id, mangaMapper) }
return handler.subscribeToList { mergedQueries.selectMergedMangasById(id, MangaMapper::mapManga) }
}
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>> {
return handler.subscribeToList { mergedQueries.selectByMergeId(id, mergedMangaReferenceMapper) }
return handler.subscribeToList { mergedQueries.selectByMergeId(id, MergedMangaMapper::map) }
}
override suspend fun updateSettings(update: MergeMangaSettingsUpdate): Boolean {
@ -122,6 +122,6 @@ class MangaMergeRepositoryImpl(
}
override suspend fun getMergeMangaForDownloading(mergeId: Long): List<Manga> {
return handler.awaitList { mergedQueries.selectMergedMangasForDownloadingById(mergeId, mangaMapper) }
return handler.awaitList { mergedQueries.selectMergedMangasForDownloadingById(mergeId, MangaMapper::mapManga) }
}
}

View File

@ -16,27 +16,27 @@ class MangaMetadataRepositoryImpl(
) : MangaMetadataRepository {
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?> {
return handler.subscribeToOneOrNull { search_metadataQueries.selectByMangaId(id, searchMetadataMapper) }
return handler.subscribeToOneOrNull { search_metadataQueries.selectByMangaId(id, ::searchMetadataMapper) }
}
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>> {
return handler.subscribeToList { search_tagsQueries.selectByMangaId(id, searchTagMapper) }
return handler.subscribeToList { search_tagsQueries.selectByMangaId(id, ::searchTagMapper) }
}
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>> {
return handler.subscribeToList { search_titlesQueries.selectByMangaId(id, searchTitleMapper) }
return handler.subscribeToList { search_titlesQueries.selectByMangaId(id, ::searchTitleMapper) }
}
override suspend fun insertFlatMetadata(flatMetadata: FlatMetadata) {
@ -58,7 +58,7 @@ class MangaMetadataRepositoryImpl(
}
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> {
@ -66,6 +66,52 @@ class MangaMetadataRepositoryImpl(
}
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(),
)
}
}

View File

@ -19,11 +19,11 @@ class MangaRepositoryImpl(
) : MangaRepository {
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> {
return handler.subscribeToOne { mangasQueries.getMangaById(id, mangaMapper) }
return handler.subscribeToOne { mangasQueries.getMangaById(id, MangaMapper::mapManga) }
}
override suspend fun getMangaByUrlAndSourceId(url: String, sourceId: Long): Manga? {
@ -31,7 +31,7 @@ class MangaRepositoryImpl(
mangasQueries.getMangaByUrlAndSource(
url,
sourceId,
mangaMapper,
MangaMapper::mapManga,
)
}
}
@ -41,34 +41,34 @@ class MangaRepositoryImpl(
mangasQueries.getMangaByUrlAndSource(
url,
sourceId,
mangaMapper,
MangaMapper::mapManga,
)
}
}
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> {
return handler.awaitListExecutable { (handler as AndroidDatabaseHandler).getLibraryQuery() }.map(libraryViewMapper)
// return handler.awaitList { libraryViewQueries.library(libraryManga) }
return handler.awaitListExecutable { (handler as AndroidDatabaseHandler).getLibraryQuery() }.map(MangaMapper::mapLibraryView)
// return handler.awaitList { libraryViewQueries.library(MangaMapper::mapLibraryManga) }
}
override fun getLibraryMangaAsFlow(): Flow<List<LibraryManga>> {
return handler.subscribeToList { libraryViewQueries.library(libraryManga) }
return handler.subscribeToList { libraryViewQueries.library(MangaMapper::mapLibraryManga) }
// SY -->
.map { getLibraryManga() }
// SY <--
}
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> {
return handler.awaitList {
mangasQueries.getDuplicateLibraryManga(title, id, mangaMapper)
mangasQueries.getDuplicateLibraryManga(title, id, MangaMapper::mapManga)
}
}
@ -180,11 +180,11 @@ class MangaRepositoryImpl(
// SY -->
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> {
return handler.awaitList { mangasQueries.getAll(mangaMapper) }
return handler.awaitList { mangasQueries.getAll(MangaMapper::mapManga) }
}
override suspend fun deleteManga(mangaId: Long) {
@ -194,7 +194,7 @@ class MangaRepositoryImpl(
override suspend fun getReadMangaNotInLibrary(): List<LibraryManga> {
return handler.awaitListExecutable {
(handler as AndroidDatabaseHandler).getLibraryQuery("M.favorite = 0 AND C.readCount != 0")
}.map(libraryViewMapper)
}.map(MangaMapper::mapLibraryView)
}
// SY <--
}

View File

@ -2,9 +2,21 @@ package tachiyomi.data.manga
import tachiyomi.domain.manga.model.MergedMangaReference
val mergedMangaReferenceMapper =
{ id: Long, isInfoManga: Boolean, getChapterUpdates: Boolean, chapterSortMode: Long, chapterPriority: Long, downloadChapters: Boolean, mergeId: Long, mergeUrl: String, mangaId: Long?, mangaUrl: String, mangaSourceId: Long ->
MergedMangaReference(
object MergedMangaMapper {
fun map(
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,
isInfoManga = isInfoManga,
getChapterUpdates = getChapterUpdates,
@ -18,3 +30,4 @@ val mergedMangaReferenceMapper =
mangaSourceId = mangaSourceId,
)
}
}

View File

@ -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(),
)
}

View File

@ -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(),
)
}

View File

@ -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(),
)
}

View File

@ -2,12 +2,18 @@ package tachiyomi.data.source
import tachiyomi.domain.source.model.FeedSavedSearch
val feedSavedSearchMapper: (Long, Long, Long?, Boolean) -> FeedSavedSearch =
{ id, source, savedSearch, global ->
FeedSavedSearch(
object FeedSavedSearchMapper {
fun map(
id: Long,
source: Long,
savedSearch: Long?,
global: Boolean
): FeedSavedSearch {
return FeedSavedSearch(
id = id,
source = source,
savedSearch = savedSearch,
global = global,
)
}
}

View File

@ -11,15 +11,15 @@ class FeedSavedSearchRepositoryImpl(
) : FeedSavedSearchRepository {
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>> {
return handler.subscribeToList { feed_saved_searchQueries.selectAllGlobal(feedSavedSearchMapper) }
return handler.subscribeToList { feed_saved_searchQueries.selectAllGlobal(FeedSavedSearchMapper::map) }
}
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 {
@ -27,15 +27,15 @@ class FeedSavedSearchRepositoryImpl(
}
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>> {
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> {
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 {

View File

@ -2,9 +2,15 @@ package tachiyomi.data.source
import tachiyomi.domain.source.model.SavedSearch
val savedSearchMapper: (Long, Long, String, String?, String?) -> SavedSearch =
{ id, source, name, query, filtersJson ->
SavedSearch(
object SavedSearchMapper {
fun map(
id: Long,
source: Long,
name: String,
query: String?,
filtersJson: String?
): SavedSearch {
return SavedSearch(
id = id,
source = source,
name = name,
@ -12,3 +18,4 @@ val savedSearchMapper: (Long, Long, String, String?, String?) -> SavedSearch =
filtersJson = filtersJson,
)
}
}

View File

@ -10,15 +10,15 @@ class SavedSearchRepositoryImpl(
) : SavedSearchRepository {
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> {
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>> {
return handler.subscribeToList { saved_searchQueries.selectBySource(sourceId, savedSearchMapper) }
return handler.subscribeToList { saved_searchQueries.selectBySource(sourceId, SavedSearchMapper::map) }
}
override suspend fun delete(savedSearchId: Long) {

View File

@ -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)
}

View File

@ -1,6 +1,7 @@
package tachiyomi.data.source
import eu.kanade.tachiyomi.source.CatalogueSource
import eu.kanade.tachiyomi.source.Source
import eu.kanade.tachiyomi.source.model.FilterList
import eu.kanade.tachiyomi.source.online.HttpSource
import exh.source.MERGED_SOURCE_ID
@ -8,38 +9,39 @@ import exh.source.isEhBasedSource
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.map
import tachiyomi.data.DatabaseHandler
import tachiyomi.domain.source.model.Source
import tachiyomi.domain.source.model.SourceWithCount
import tachiyomi.domain.source.model.StubSource
import tachiyomi.domain.source.repository.SourcePagingSourceType
import tachiyomi.domain.source.repository.SourceRepository
import tachiyomi.domain.source.service.SourceManager
import tachiyomi.domain.source.model.Source as DomainSource
class SourceRepositoryImpl(
private val sourceManager: SourceManager,
private val handler: DatabaseHandler,
) : SourceRepository {
override fun getSources(): Flow<List<Source>> {
override fun getSources(): Flow<List<DomainSource>> {
return sourceManager.catalogueSources.map { sources ->
sources.map {
sourceMapper(it).copy(
mapSourceToDomainSource(it).copy(
supportsLatest = it.supportsLatest,
)
}
}
}
override fun getOnlineSources(): Flow<List<Source>> {
override fun getOnlineSources(): Flow<List<DomainSource>> {
return sourceManager.catalogueSources.map { sources ->
sources
.filterIsInstance<HttpSource>()
.map(sourceMapper)
.map(::mapSourceToDomainSource)
}
}
override fun getSourcesWithFavoriteCount(): Flow<List<Pair<Source, Long>>> {
val sourceIdWithFavoriteCount = handler.subscribeToList { mangasQueries.getSourceIdWithFavoriteCount() }
override fun getSourcesWithFavoriteCount(): Flow<List<Pair<DomainSource, Long>>> {
val sourceIdWithFavoriteCount =
handler.subscribeToList { mangasQueries.getSourceIdWithFavoriteCount() }
return sourceIdWithFavoriteCount.map { sourceIdsWithCount ->
sourceIdsWithCount
// SY -->
@ -47,7 +49,7 @@ class SourceRepositoryImpl(
// SY <--
.map { (sourceId, count) ->
val source = sourceManager.getOrStub(sourceId)
val domainSource = sourceMapper(source).copy(
val domainSource = mapSourceToDomainSource(source).copy(
isStub = source is StubSource,
)
domainSource to count
@ -56,11 +58,12 @@ class SourceRepositoryImpl(
}
override fun getSourcesWithNonLibraryManga(): Flow<List<SourceWithCount>> {
val sourceIdWithNonLibraryManga = handler.subscribeToList { mangasQueries.getSourceIdsWithNonLibraryManga() }
val sourceIdWithNonLibraryManga =
handler.subscribeToList { mangasQueries.getSourceIdsWithNonLibraryManga() }
return sourceIdWithNonLibraryManga.map { sourceId ->
sourceId.map { (sourceId, count) ->
val source = sourceManager.getOrStub(sourceId)
val domainSource = sourceMapper(source).copy(
val domainSource = mapSourceToDomainSource(source).copy(
isStub = source is StubSource,
)
SourceWithCount(domainSource, count)
@ -101,4 +104,12 @@ class SourceRepositoryImpl(
// SY <--
return SourceLatestPagingSource(source)
}
private fun mapSourceToDomainSource(source: Source): DomainSource = DomainSource(
id = source.id,
lang = source.lang,
name = source.name,
supportsLatest = false,
isStub = false,
)
}

View File

@ -10,14 +10,20 @@ class StubSourceRepositoryImpl(
) : StubSourceRepository {
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? {
return handler.awaitOneOrNull { sourcesQueries.findOne(id, sourceDataMapper) }
return handler.awaitOneOrNull { sourcesQueries.findOne(id, ::mapStubSource) }
}
override suspend fun upsertStubSource(id: Long, lang: String, name: String) {
handler.await { sourcesQueries.upsert(id, lang, name) }
}
private fun mapStubSource(
id: Long,
lang: String,
name: String,
): StubSource = StubSource(id = id, lang = lang, name = name)
}

View File

@ -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,
)
}

View File

@ -10,38 +10,38 @@ class TrackRepositoryImpl(
) : TrackRepository {
override suspend fun getTrackById(id: Long): Track? {
return handler.awaitOneOrNull { manga_syncQueries.getTrackById(id, trackMapper) }
return handler.awaitOneOrNull { manga_syncQueries.getTrackById(id, ::mapTrack) }
}
// SY -->
override suspend fun getTracks(): List<Track> {
return handler.awaitList {
manga_syncQueries.getTracks(trackMapper)
manga_syncQueries.getTracks(::mapTrack)
}
}
override suspend fun getTracksByMangaIds(mangaIds: List<Long>): List<Track> {
return handler.awaitList {
manga_syncQueries.getTracksByMangaIds(mangaIds, trackMapper)
manga_syncQueries.getTracksByMangaIds(mangaIds, ::mapTrack)
}
}
// SY <--
override suspend fun getTracksByMangaId(mangaId: Long): List<Track> {
return handler.awaitList {
manga_syncQueries.getTracksByMangaId(mangaId, trackMapper)
manga_syncQueries.getTracksByMangaId(mangaId, ::mapTrack)
}
}
override fun getTracksAsFlow(): Flow<List<Track>> {
return handler.subscribeToList {
manga_syncQueries.getTracks(trackMapper)
manga_syncQueries.getTracks(::mapTrack)
}
}
override fun getTracksByMangaIdAsFlow(mangaId: Long): Flow<List<Track>> {
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,
)
}

View File

@ -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,
),
)
}

View File

@ -4,8 +4,10 @@ import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.map
import tachiyomi.data.AndroidDatabaseHandler
import tachiyomi.data.DatabaseHandler
import tachiyomi.domain.manga.model.MangaCover
import tachiyomi.domain.updates.model.UpdatesWithRelations
import tachiyomi.domain.updates.repository.UpdatesRepository
import tachiyomi.view.UpdatesView
class UpdatesRepositoryImpl(
private val databaseHandler: DatabaseHandler,
@ -21,17 +23,17 @@ class UpdatesRepositoryImpl(
read = read,
after = after,
limit = limit,
mapper = updateWithRelationMapper,
mapper = ::mapUpdatesWithRelations,
)
}
}
override fun subscribeAll(after: Long, limit: Long): Flow<List<UpdatesWithRelations>> {
return databaseHandler.subscribeToList {
updatesViewQueries.getRecentUpdates(after, limit, updateWithRelationMapper)
updatesViewQueries.getRecentUpdates(after, limit, ::mapUpdatesWithRelations)
}.map {
databaseHandler.awaitListExecutable { (databaseHandler as AndroidDatabaseHandler).getUpdatesQuery(after, limit) }
.map(updatesViewMapper)
.map(::mapUpdatesView)
}
}
@ -45,8 +47,67 @@ class UpdatesRepositoryImpl(
read = read,
after = after,
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,
),
)
}
}