fix(sqldelight): Custom query function

Basically the same as "executeAsOneOrNull" but without the result count
check
This commit is contained in:
Ahmad Ansori Palembani 2024-12-02 13:13:37 +07:00
parent 2fd6146d32
commit 7f05d16039
Signed by: null2264
GPG key ID: BA64F8B60AF3EFB6
5 changed files with 30 additions and 4 deletions

View file

@ -23,7 +23,7 @@ class ChapterRepositoryImpl(private val handler: DatabaseHandler) : ChapterRepos
handler.awaitList { chaptersQueries.getChaptersByUrl(url, filterScanlators.toInt().toLong(), Chapter::mapper) }
override suspend fun getChapterByUrl(url: String, filterScanlators: Boolean): Chapter? =
handler.awaitOneOrNull { chaptersQueries.getChaptersByUrl(url, filterScanlators.toInt().toLong(), Chapter::mapper) }
handler.awaitFirstOrNull { chaptersQueries.getChaptersByUrl(url, filterScanlators.toInt().toLong(), Chapter::mapper) }
override suspend fun getChaptersByUrlAndMangaId(
url: String,
@ -39,7 +39,7 @@ class ChapterRepositoryImpl(private val handler: DatabaseHandler) : ChapterRepos
mangaId: Long,
filterScanlators: Boolean
): Chapter? =
handler.awaitOneOrNull {
handler.awaitFirstOrNull {
chaptersQueries.getChaptersByUrlAndMangaId(url, mangaId, filterScanlators.toInt().toLong(), Chapter::mapper)
}

View file

@ -16,7 +16,7 @@ class MangaRepositoryImpl(private val handler: DatabaseHandler) : MangaRepositor
handler.awaitList { mangasQueries.findAll(Manga::mapper) }
override suspend fun getMangaByUrlAndSource(url: String, source: Long): Manga? =
handler.awaitOneOrNull { mangasQueries.findByUrlAndSource(url, source, Manga::mapper) }
handler.awaitFirstOrNull { mangasQueries.findByUrlAndSource(url, source, Manga::mapper) }
override suspend fun getMangaById(id: Long): Manga? =
handler.awaitOneOrNull { mangasQueries.findById(id, Manga::mapper) }
@ -37,7 +37,7 @@ class MangaRepositoryImpl(private val handler: DatabaseHandler) : MangaRepositor
handler.subscribeToList { library_viewQueries.findAll(LibraryManga::mapper) }
override suspend fun getDuplicateFavorite(title: String, source: Long): Manga? =
handler.awaitOneOrNull { mangasQueries.findDuplicateFavorite(title.lowercase(), source, Manga::mapper) }
handler.awaitFirstOrNull { mangasQueries.findDuplicateFavorite(title.lowercase(), source, Manga::mapper) }
override suspend fun update(update: MangaUpdate): Boolean {
return try {